草庐IT

istream_iterators

全部标签

c++ - boost 图形库 : Bundled Properties and iterating across edges

只是想了解一下BoostGraphLibrary,我有几个问题。我正在编写一些代码,它是BGL图的包装类。我的想法是,我可以随心所欲地操作图表,然后调用包装方法以GEXF(XML)格式输出图表。我的代码是这样的:structVertex{std::stringlabel;...};structEdge{std::stringlabel;doubleweight;...};typedefboost::adjacency_listGraphType;templateclassGEXF{private:Graphgraph;...};templatevoidGEXF::buildXML(){

c++ - 具有不完整 Value 参数的 Boost.Iterator Facade

我正在尝试将boost::iterator_facade与不完整的Value一起使用模板参数。这失败了,因为iterator_facade正试图检查类型is_pod。这是预期的行为吗?我可以解决这个限制吗某种方式?我可以编写一个简单地代理foo和为它提供隐式转换,但我宁愿有一个更简单的解决方案。#includeclassiter:publicboost::iterator_facade{private:friendclassboost::iterator_core_access;voidincrement(){}boolequal(iterconst&other)const{retur

c++ - boost::spirit 1.53 multi_pass iterator相关的编译错误

代码:typedefstd::string::const_iteratoriterator;namespaceparsers{namespacespirit=::boost::spirit;namespaceascii=::boost::spirit::ascii;namespacephoenix=::boost::phoenix;spirit::qi::ruleaction_parser='"'>spirit::qi::lit("action")>spirit::qi::labels::_r1>'"';}错误:>1>CL:warning:Thisheaderisdeprecated.

c++ - std::deque: "insertion and deletion of elements may invalidate iterators"是什么意思?

我正在阅读有关std::deque容器的信息,文档指出Insertionanddeletionofelementsinstd::dequemayinvalidateallitsiterators这是我对上述陈述的理解版本,如果我误解了陈述或遗漏了什么,请告诉我考虑以下代码std::deques;s.push_back(12);autoi=s.begin();s.push_front(45);//Afterpushing45atthebacknow`i`maybeinvalid.这个理解正确吗? 最佳答案 你是对的。例如之后std::

c++ - C++11 中的 checked_array_iterator<T>

C++11提供了std::array包装C数组,但仅限于在编译时知道数组大小的地方。处理大小仅在运行时已知的数组的最佳方法是什么?背景我正在将一些代码从MSVC移植到GCC。MSVC提供了stdext::checked_array_iterator为这样的代码行提供一些保护的模板:std::copy(v.begin(),v.end(),stdext::checked_array_iterator(arr,numVals));到目前为止,我可以想到两种选择:放弃安全检查或编写自己的实现。关于这一点,如果您对此实现提出任何建设性意见,我将不胜感激:namespacestdext{templ

c++ - std::iterator_traits libstdc++ 和 libc++ 之间的分歧

给定:structIter{usingvalue_type=int;usingdifference_type=int;usingreference=int;usingpointer=int;usingiterator_category=int;};以下代码适用于libstc++,但无法针对libc++5.0.0进行编译:#include#includestatic_assert(std::is_same::iterator_category,Iter::iterator_category>::value,"");出现错误:error:nomembernamed'iterator_cat

c++ - 我如何在 wxWidgets 中重定向标准输入(istream)?

我正在尝试弄清楚如何将istream重定向到wxwidgets。我能够完成重定向ostream,方法如下(所以你知道我的意思):wxTextCtrl*stdoutctrl=newwxTextCtrl(...);wxStreamToTextRedirectorredirect(stdoutctrl);//Redirectostreamstd::cout我现在已经搜索了一段时间,但我找不到我将istream重定向到某种wx-input(所以“cin”实际上会提示用户通过wxWidgets输入)。 最佳答案 不,没有内置的方法可以做到这一

c++ - boost::asio::streambuf 断言 "iterator out of bounds"

客户端向服务器发送大约165kB的数据。起初一切都很好。但是当客户端再次发送相同的数据(165kB)时,我在服务器端收到一个断言。断言包含有关“迭代器越界”的信息在调用堆栈上,有一些关于read_until方法的信息。所以我认为我犯了一个错误。TCP异步服务器代码如下:handle_read代码:voidSession::handle_read(constboost::system::error_code&a_error,size_ta_nbytestransferred){if(!a_error){std::ostringstreamdataToRetrive;dataToRetri

c++ - istream 和 ostream 跨平台

假设我想在我的大端机器上写这个an_ostream_implmy_output_on_BE;my_output_on_BE这是在我的小端机器上an_istream_implmy_input_on_LE;__int32value;my_input_on_LE>>value;assert(value==0x1234);是否有允许这样做的istream/ostream实现?例如。总是以BigEndian(或任何格式)流式传输数字? 最佳答案 如果您需要在机器之间共享比单个整数更复杂的数据,我衷心推荐GoogleProtocolBuffer

c++ - 将基于自定义模板的迭代器类的对象转换为 const_iterator

我正在大学学习OOP类(class)(C++是基础语言)。我的任务是实现自己的链表模板容器类。我几乎完全做到了,但遇到了问题。已知STL提供iterator和const_iterator通过列表进行迭代的类。它们具有几乎相同的实现,主要区别在于iterator的方法返回引用,而const_iterator的方法——常量引用。我关注了https://stackoverflow.com/a/3582733/2108548并创建了单独的模板类ListIterator.然后我用typedef声明类(class)Iterator和ConstIterator类内List.我有这样的东西:templ