草庐IT

match_first

全部标签

c++ - regex_match 有什么问题?很简单的表达

我正在使用VS2010并编写C++控制台应用程序并遇到问题#includeusingnamespacestd;//...if(!regex_match("abab",regex("(ab?)*"))){//theproblemis-whywearehere?whyitdoesn'tmatch?}在这里查看http://regexpal.com/-它匹配 最佳答案 非常简单:regex_match仅在整个序列匹配时才返回true。如果您想查看一个字符串是否包含您的正则表达式,您可能需要使用regex_search。“是吗?”匹配“ab

c++ - boost 图中的颜色图 breadth_first_visit

我想使用boostsbreadth_first_visit方法,我想为它提供我自己的“外部”颜色图。我定义的图如下typedefboost::adjacency_list>>GraphType;其中Node_t是一个结构体,用于定义顶点的属性。但是,我无法找到如何为BFS提供我自己的颜色图。我想将顶点颜色存储在一个vector中,所以我的定义看起来像std::vectorcolors;但我想不通,如何将其用于bfs。都不是boost::breadth_first_search(g,*boost::vertices(g).first,boost::color_map(colors));也

c++ - "error: no matching function for call to"构造未初始化的结构时

我正在尝试使用boost::lockfree::spsc_queue有了这个websocketserver而不是std::queue用于m_actions以包含此struct:enumaction_type{SUBSCRIBE,UNSUBSCRIBE,MESSAGE};structaction{action(action_typet,connection_hdlh):type(t),hdl(h){}action(action_typet,server::message_ptrm):type(t),msg(m){}action_typetype;websocketpp::connecti

c++ - 从基类继承两次时如何修复 "error: no matching function for call to"

我目前正在尝试在我的项目中实现一系列继承类。因此,我使用成员初始值设定项列表并将对变量的引用“管道化”到基类。我真的不确定,为什么我会收到编译器错误。我已经尝试将引用“int&id”更改为指针“int*id”。上面的示例只是指出我的问题的最小示例:classBase{public:int&m_id;Base(int&id):m_id(id){}};classDerived1:virtualpublicBase{public:Derived1(int&id):Base(id){};};classDerived2:publicDerived1{public:Derived2(int&id)

c++ - Boost find_first 它是如何工作的?/定义一个范围

我有一个缓冲区(例如charbuffer[1024]),其中填充了一些数据。现在我想在这个缓冲区中搜索一个子字符串。因为它应该是一个不区分大小写的搜索,所以我正在使用boost::algorithm::ifind_first。所以我这样调用这个函数:boost::iterator_rangebuf_iterator;buf_iterator=boost::algorithm::ifind_first(buffer,"substring");这实际上工作正常。但我担心的是:我只向函数传递了一个charpointer,所以ifind_first应该不知道我的缓冲区在哪里结束,但它仍然有效。

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++ - 为什么在核心转储中得到 "first/second chance not available"

我使用windbg调试故障转储,在windbg的以下输出中,您可以看到“first/secondchancenotavailable”,为什么first/secondchance不可用?这是什么意思?Thisdumpfilehasanexceptionofintereststoredinit.Thestoredexceptioninformationcanbeaccessedvia.ecxr.(e38.2270):Accessviolation-codec0000005(first/secondchancenotavailable) 最佳答案

c++ - 模板错误 : no matching function call

我正在通过加速C++工作,遇到了Ex问题。10.2这些问题涉及重写上一章的中值函数,以便现在可以使用vector或内置数组调用中值。中值函数还应该允许任何算术类型的容器。我无法对下面详述的median进行两次调用-我收到了错误消息Nomatchingfunctionforcallto'median'我从一些研究中了解到,当使用模板时,应该在编译时知道类型。这可能是根本问题吗?有没有办法以某种方式将Type作为模板参数传递?到目前为止,这是我的代码:#include#include#include#include#includeusingnamespacestd;templateType

C++ 错误 : no match for call to ‘(std::string {aka std::basic_string<char>}) (std::string&)’

我是C++新手。我搜索了很多次,但仍然得不到答案。我正在写一个名为Course的类(class)来描述学生在学校上的类(class)。Course类有3个字段:protected:stringcourseName;intcourseNum;floatscore;我有一个公共(public)方法“setName”来设置类(class)名称:Course&setName(stringname){this->courseName(name);return(*this);}但是,当我尝试编译时,编译器会提示:C++错误:对“(std::string{akastd::basic_string})

c++ - "no base classes of the same type as the first non-static data member"

我askedthisawhileago在comp.std.c++上并没有得到答复。我只是要在那里引用我的帖子,稍作修改。标准布局类的最后一个要求9/6是必要的还是有用的?提供了脚注解释:Thisensuresthattwosubobjectsthathavethesameclasstypeandthatbelongtothesamemost-derivedobjectarenotallocatedatthesameaddress(5.10).单独来看,脚注是不正确的。两个空基类公共(public)基类可能会产生基类的两个实例同一个地址。structA{};structB:A{};str