草庐IT

sregex_token_iterator

全部标签

c++ - 为什么 boost filter_iterator 有奇怪的 make_filter_iterator 函数?

在经历了一些痛苦之后,我设法拼凑了这个boostfilter_iterator的最小示例usingnamespacestd;std::functionstlfunc=[](uint32_tn){returnn%3==0;};intmain(){vectornumbers{11,22,33,44,55,66,77,3,6,9};autostart=boost::make_filter_iterator(stlfunc,numbers.begin(),numbers.end());autoend=boost::make_filter_iterator(stlfunc,numbers.end

c++ - 错误 LNK2020 : unresolved token (06000002) in Visual C++

我在C++/CLI中创建一个新的抽象类时遇到了一个奇怪的错误。有很多与此类似的问题,但没有一个答案对我有帮助。在这个新类(class)中,我收到以下错误:errorLNK2020:unresolvedtoken(06000002)Foo::execute这是h文件:#pragmaonceusingnamespaceSystem::IO::Ports;usingnamespaceSystem;publicrefclassFoo{protected:SerialPort^port;public:Foo(SerialPort^sp);virtualarray^execute();};这是cp

c++ - map<T,T>::iterator 作为参数类型

我有一个带有私有(private)映射成员的模板类templateclassMyClass{public:MyClass(){}private:std::mapmyMap;}我想创建一个接受映射迭代器的私有(private)方法voidMyFunction(std::map::iterator&myIter){....}但是,这会出现编译错误:标识符“迭代器”。我不需要传递一个抽象迭代器,因为MyFunction知道它是一个映射迭代器(并且只会用作myMap的交互器)并且会这样对待它(访问和修改myIter->second)。将myIter->second传递给MyFunction是不

关于LLaMA Tokenizer的一些坑...

使用LLaMATokenizer对jsonl文件进行分词,并将分词结果保存到txt文件中,分词代码如下:importjsonlinesimportsentencepieceasspmfromtqdmimporttqdmjsonl_file='/path/to/jsonl_file'txt_file='/path/to/txt_file'tokenizer=spm.SentencePieceProcessor('./tokenizer.model')w=open(txt_file,mode='w',encoding='utf-8')withjsonlines.open(jsonl_file,mo

c++ - Boost Spirit 信号成功解析,尽管 token 不完整

我有一个非常简单的路径构造,我正在尝试使用boostspirit.lex进行解析。我们有以下语法:token:=[a-z]+path:=(token:path)|(token)所以我们在这里只讨论冒号分隔的小写ASCII字符串。我有三个示例“xyz”、“abc:xyz”、“abc:xyz:”。前两个应该被认为是有效的。第三个以冒号结尾,不应被视为有效。不幸的是,我的解析器认为这三个都是有效的。语法不应允许空标记,但显然spirit正在这样做。我错过了什么让第三个被拒绝?此外,如果您阅读下面的代码,在注释中有另一个版本的解析器要求所有路径以分号结尾。当我激活这些行时,我可以获得适当的行为

c++ - ‘*’ token 之前的预期初始值设定项

我正在尝试实现设计模式书中的代码。我收到以下错误:expectedinitializerbefore‘*’token对于这一行:staticSingleton*Singleton::itsInstance=0;这是完整的代码。我正在使用g++4.2.1来尝试编译它。classSingleton{public:staticSingleton*instance();protected:Singleton();private:staticSingleton*itsInstance;}staticSingleton*Singleton::itsInstance=0;Singleton*Sing

c++ - "vector iterator + offset out of range"断言有用吗?

这个完美的程序在VisualStudio2013的Debug模式下失败:#include#include#includeusingnamespacestd;voidmain(){vectorv={3,1,4,1,5,9,2,6,5,3};for(autoiFrom=v.cbegin(),iTo=iFrom+5;iFrom!=v.cend();iFrom=iTo,iTo+=5)coutvectoriterator+offsetoutofrange断言失败。它失败是因为iTo>v.cend(),这在这里是无害的。调试器测试没有被取消引用的迭代器的值有什么意义?顺便说一句,我知道我可以将上面

C++:std::istream 检查 EOF 而不读取/消耗 token /使用运算符>>

我想测试std::istream是否已经到达结尾而不读取它。我知道我可以像这样检查EOF:if(is>>something)但这有一系列的问题。想象有许多(可能是虚拟的)方法/函数期望std::istream&作为参数传递。这意味着我必须做一些检查EOF的“家务”,可能使用不同类型的something变量,或者创建一些奇怪的包装器来处理调用输入法的情况.我需要做的就是:if(!IsEof(is))Input(is);IsEof方法应保证流不会因读取而改变,因此上面的行等同于:Input(is)关于在Input方法中读取的数据。如果没有通用的解决方案来表示和std::istream,有没

c++ - C++ : "expected primary-expression before ‘>’ token"中的两个模板

这个问题在这里已经有了答案:WhereandwhydoIhavetoputthe"template"and"typename"keywords?(8个答案)关闭7年前。最小工作示例:#includestructPrinter{templatestaticvoidprint(Telem){std::coutstructMain{templatevoidprint(Telem){//Inthiscase,thecompilercouldguessTfromthecontext//Butinmycase,assumethatIneedtospecifyT.printer_t::print(e

c++ - C++ 代码错误 "expected constructor, destructor, or type conversion before ‘(’ token ”和 "no matching function for call to ..."

真正尝试解决错误,仔细检查所有内容。请帮忙。c++新手,请多关照。头文件(.h)#ifndefGUARD_Optimized_quick_sort_h#defineGUARD_Optimized_quick_sort_h#include#include#includeusingnamespacestd;templateclassoptimized_quick_sort{public:optimized_quick_sort(vectorarray){this->array=array;}optimized_quick_sort(listarray){vectortemp(array.b