草庐IT

recursive_directory_iterator

全部标签

c++ - Boost Single Pass Iterator 和 Forward Traversal Iterator 有什么区别?

在NewIteratorConceptsstandardproposal,我无法破译单遍迭代器和前向遍历迭代器之间的任何有用区别。前向遍历表中“++r”行的“断言/注释”是否暗示前向遍历迭代器是可复制的,而单遍迭代器不是?此外,为什么默认构造的额外能力会产生迭代器模型正向遍历?原理是什么? 最佳答案 单遍迭代器的想法是它比正向遍历迭代器具有更少的要求。这样就可以为某些无法进行多次传递的情况创建一个。想想控制台输入。即使您可以复制迭代器,也无法帮助您检索旧的键盘输入。 关于c++-Boos

C++11 regex_token_iterator

嗯...我以为我理解正则表达式,我以为我理解迭代器,但C++11的正则表达式实现让我感到困惑...一个我不明白的地方:阅读regextokeniterators,我遇到了以下示例代码:#include#include#include#include#includeintmain(){std::stringtext="Quickbrownfox.";//tokenization(non-matchedfragments)//Notethatregexismatchedonlytwotimes:whenthethirdvalueisobtained//theiteratorisasuffi

c++ - 提升 : is it safe to use multiple recursion in async calls?

我是asio框架的新手,所以请多多关照。我调查了几个boostasio示例,发现人们使用这样的异步调用:voidread(){async_read(socket_,boost::asio::buffer(&user_[0],user_.size()),boost::bind(&Connection::handle_user_read,this,placeholders::error,placeholders::bytes_transferred));}voidhandle_user_read(...){...read();...}我认为这段代码不安全,因为它使用了多重递归。所以当因为调

c++ - 迭代器 - vector::iterator 和 array::iterator 的重载函数

我只是想重载某个函数连续容器的迭代器(它们是std::vector::iterator、std::array::iterator和内置数组迭代器==原始指针)可以是有效参数。出于某种原因,我的函数无法针对vector和std::array进行编译:功能:templatevoidcatchIterator(typenamestd::array::iteratorit){//dosomthing}templatevoidcatchIterator(typenamestd::vector::iteratorit){//dosomthing}使用示例:std::arrayarr;autoit=

c++ - boost spirit istream_iterator 从流中消耗太多

考虑从更复杂的代码中提取的以下示例:#include#include#include#include#include#include#includenamespaceqi=boost::spirit::qi;namespacephx=boost::phoenix;//TheclassimplementsaXMLtagstoringthenameandavariablenumberofattributes:structTag{//ThetypedefdefinesthetypeusedforaXMLname:typedefstd::stringname_type;//Thetypedef

c++ - boost::transform_iterator 不适用于 std::bind( &Pair::first, _1 )?

通过std::map的键集进行迭代的传统任务将我引向了另一个似乎尚未在此处讨论的困惑局面。简而言之,这段代码无法编译(大量使用C++11):typedefstd::pairPair;vectorv{Pair(1,2),Pair(2,3)};usingnamespacestd::placeholders;autochoose_first=std::bind(&Pair::first,_1);boost::make_transform_iterator(v.begin(),choose_first);错误信息如下。notypenamed'result_type'in'structstd::

c++ 范围的排序 View - 如何创建 const_iterator?

我正在尝试编写一个类,该类应充当某些基础元素序列的排序View。到目前为止,我提出了一个非const版本。现在我在调整它以提供const_iterator功能时遇到了问题。我目前的代码如下所示://forwarddeclareiteratortemplateclasssorted_range_iter;templateclasssorted_range{friendclasssorted_range_iter;private:usingT=typenameInputIt::value_type;InputIt_first;InputIt_last;std::vector_indices

c++ - 访问 std::recursive_mutex 使用的所有者计数器

我有一个案例,我的算法的决定是基于共享std::recursive_mutex的深度。#include#include#includeintg_i=0;std::recursive_mutexg_i_mutex;voidbar(){std::lock_guardlock(g_i_mutex);switch(get_counter(g_i_mutex)){//somewaytofindthenumberofownerscase1:std::coutlock(g_i_mutex);std::cout我读到递归互斥锁保存某种使用计数,并且它们会随着每次锁定/解锁调用而增加和减少它,有没有办法

c++ - 为什么 *_iterators 在移除 std::iterator 后仍然需要 typedef something void?

我使用ostreambuf_iterator如下图:在c++17之前,template>classostreambuf_iterator:publicstd::iterator要求我们确定std::iterator的每个参数类型,因此,对于std::ostreambuf_iterator,void还不错。据我们所知,std::iterator在c++17中已弃用。因此,迭代器应该在它们自己的主体中对它们的成员类型进行typedef,例如:MembertypeDefinition---------------------------------------------value_type

c++ - 如何复制 boost::filesystem::directory_iterator?

我知道这听起来很愚蠢,但看看这个简单的例子(工作目录应该有多个项目):#defineBOOST_FILESYSTEM_VERSION3#include#includeintmain(){usingnamespaceboost::filesystem;directory_iteratorit("./");directory_iteratorit_copy=it;++it;assert(it_copy!=it);return0;}it_copy是和it一起修改的!(boost1.45)什么样的考虑会导致这样的设计(directory_iterator类似于smartptr)?我只需要保存一