草庐IT

reverse_iter

全部标签

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++ - 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++ - 将基于自定义模板的迭代器类的对象转换为 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

c++ - 为什么箭头运算符 "->"不能在 boost::numeric::ublas::vector<...>::iterator 上工作?

考虑这段代码:structCData{intbar(){return1;}};intmain(){typedefboost::numeric::ublas::vectorvec_data_t;vec_data_tfoo;for(vec_data_t::iteratorit=foo.begin();it!=foo.end();++it){std::coutbar()为什么循环中使用箭头运算符的第一行编译失败,而使用运算符*的下一行编译正常?我习惯于将箭头运算符与std容器迭代器一起使用,想知道为什么它在boost::numeric::ublas迭代器上失败。我使用的是boost1.54和

c++ - 在 C++ 中将惰性生成器实现为 forward_iterator

MyGenerator代表一个(可能)有限的整数序列,计算起来很昂贵。所以我不想预先生成它们并将它们放入容器中。structMyGenerator{boolHasNext();intNext();}全部打印:MyGeneratorgenerator;while(generator.HasNext()){std::cout如何实现类似的遵循forward_iterator协议(protocol)的生成器?boost::function_input_iterator接近,但我不知道预先元素的数量。 最佳答案 首先,查看boost::fu