草庐IT

c++ - 错误 : ‘list’ is not a member of ‘std’ and error: template argument 2 is invalid

我正在尝试编译我的头文件,但我遇到了我无法弄清楚的错误。我想创建一个包含3个映射的结构:-从单个单词映射到计数-从词对映射到计数-从单个单词映射到后续单词列表我的头文件中的代码:#include#include#include#include#include#include#include#includetypedefstruct{std::mapfirstCounts;std::mappairCounts;std::map>follows;//Youcanuseaniteratortoretrievethevaluesstoredinthelist.}LanguageModel;我得

c++ - c++ : error: must use '.*' or '->*' to call pointer-to-member function in function 中的函数指针

代码片段如下。无法理解为什么会出现此错误。voidSipObj::check_each_field(){map::iteratormsg;stringstr;charname[20];boolres=false;sscanf(get_payload(),"%s%*s",name);LOGINFO(lc())second;res=(this).*sip_field();}}typedefbool(SipObj::*sip_field_getter)();staticmapsip_field_map;sip_field_getter是函数名的占位符 最佳答案

c++ - 无法将 "member pointer to derived class"转换为 "member pointer to base class"

使用指向基类的指针调用类的虚成员函数当然是C++中非常常见的事情。所以我觉得很奇怪,当你有一个成员指针而不是一个普通指针时,似乎不可能做同样的事情。请考虑以下代码:structB{virtualvoidf();};structD:B{virtualvoidf();};structE{Bb;Dd;};intmain(){Ee;//Firstwithnormalpointers:B*pb1=&e.b;//OKB*pb2=&e.d;//OK,BisabaseofDpb1->f();//OK,callsB::f()pb2->f();//OK,callsD::f()//Nowwithmember

C++11/14 : How to remove a pointer-to-member from a type?

在C++11或C++1y/14中:给定一个TC::*形式的指向成员类型的值,我想得到指向类型例如:#includeusingnamespacestd;structT1{staticvoidf(){coutstructV;templatestructV{staticconstexprT1U1::*pm=&U1::x;};templatestructV{staticconstexprT2U2::*pm=&U2::x;};templatevoidf(Wpm){typedef???T;T::f();}intmain(){f(V::pm);f(V::pm);}有没有办法做到这一点?上面的???是

c++ - Lambda 捕获列表 : capturing object's member field by value not possible without capturing the whole object?

下面的代码voidCMainWindow::someMethod(constCLocationsCollection&parentItem){autof=[this,parentItem.displayName](){};}给我一​​个错误:errorC2143:syntaxerror:missing']'before'.'如果我想通过ref捕获parentItem.displayName,我会为它创建一个非依赖别名标识符:constQString&name=parentItem.displayName;autof=[this,&name](){};//Orshoulditbe[thi

C++11 : error: ‘begin’ is not a member of ‘std’

我正在尝试执行以下操作:source=newint[10];dest=newint[10];std::copy(std::begin(source),std::end(source),std::begin(dest));但是,编译器报如下错误。copy.cpp:5434:14:error:‘begin’isnotamemberof‘std’copy.cpp:5434:44:error:‘end’isnotamemberof‘std’copy.cpp:5434:72:error:‘begin’isnotamemberof‘std’我已经包含了所需的代码中的header。有人可以帮我解决这

c++ - '&' : illegal operation on bound member function expression

这个问题在这里已经有了答案:Printaddressofvirtualmemberfunction(5个答案)关闭7年前。当我尝试从具有主要功能的单个cpp文件时,这有效,sprintf(smem_options,"#transcode{vcodec=RV24}:smem{""video-prerender-callback=%lld,""no-time-sync},",(longlongint)(intptr_t)(void*)&cbVideoPrerender);如何在类中将函数参数传递给sprintf?sprintf(smem_options,"#transcode{vcodec

c++ - std::is_member_function_pointer 不适用于 noexcept 成员函数

我在使用std::is_member_function_pointer时遇到问题。据我所知,在给定noexcept成员函数时它不起作用。我在标准中找不到任何声明它不适用于noexcept合格成员函数的内容。问题示例:#includeclassA{public:voidmember()noexcept{}};intmain(){//failsatcompiletimeifA::memberisadatamemberandnotafunctionstatic_assert(std::is_member_function_pointer::value,"A::memberisnotamemb

c++ - decltype( (A{}.int_member) ) 的正确结果是什么?

给定类型A的定义:structA{inti;};根据规范[expr.ref](我使用了n4618):(ifE2isnon-reference,)...IfE1isanlvalue,thenE1.E2isanlvalue;otherwiseE1.E2isanxvalue...显然A{}.i是xvalue;还考虑到[dcl.type.simple]:(fordecltype(e),)—...ifeisanunparenthesizedid-expressionoranunparenthesizedclassmemberaccess...—otherwise,ifeisanxvalue,de

c++ - 错误 C2039 : 'find' : is not a member of 'std'

我刚遇到一个奇怪的错误,说find不是std的成员。errorC2039:'find':isnotamemberof'std'errorC3861:'find':identifiernotfound基本上,我想查找是否可以在vector中找到一个字符串知道为什么会这样吗?代码帮助告诉我在std中有find方法。这基本上就是我所做的:#include"OperatorUtil.h"#include#include#include#include#includeusingnamespacesaeConfig;namespaceoperatorUtil{boolisIn(constFilte