草庐IT

non-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++ - 迭代器 - 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 使调试构建依赖于 "non-D"MSVC 运行时 DLL

我有一个烦人的问题,我可能能够以某种方式规避它,但另一方面,我更愿意了解它并了解到底发生了什么,因为看起来这些东西真的会留下来。故事是这样的:我有一个简单的OpenGL应用程序,它运行良好:在编译、链接或运行它时从来都不是主要问题。现在我决定尝试将一些更密集的计算移到工作线程中,以便可能使GUI响应更快——当然是使用Boost.Thread。简而言之,如果我在.cpp文件的开头添加以下片段:#includevoiddummyThreadFun(){while(1);}boost::threadp(dummyThreadFun);,然后我在尝试启动调试版本时开始收到“此应用程序无法启动,

C++, Linux : error: conversion from ‘boost::unique_future<void>’ to non-scalar type ‘boost::shared_future<void>’ requested. 如何绕过它?

我尝试使用boostthreadfutures.所以如图here我们可以得到sharedfuture来自packagedtask.所以我在linux上尝试这样的功能:templatevoidpool_item(boost::shared_ptr>pt){boost::shared_futurefi=pt->get_future();//error//...但调用它时出错:../../src/cf-util/thread_pool.h:Inmemberfunction‘voidthread_pool::pool_item(boost::shared_ptr>)[withtask_retu

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++ - 为什么 *_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)?我只需要保存一