草庐IT

c++ - "no matching function for call to ‘async(std::launch, <unresolved overloaded function type>, std::string&)’“

我正在尝试使用std::async创建线程,但我不断收到错误“没有匹配函数调用‘async(std::launch,,std::string&)’”在行上ConnectFuture=std::async(std::launch::async,Connect_T,ip);这是产生这种行为的代码:#includeclasslibWrapper{public:voidConnect(std::stringip);voidConnect_T(std::stringip);private:std::futureConnectFuture;};voidlibWrapper::Connect(std

c++ - 错误 : no matching member function for call to 'push_back'

为什么我在最后两行收到错误?目标是在集合中找到对象,并修改其内容。usingnamespacestd;structmystruct{intid;vectory;mystruct(constintid):id(id){}booloperatorsx;mystructx(1);x.y.push_back(1);x.y.push_back(2);sx.insert(x);//set::iteratori=sx.find(1);constmystruct*x1=&(*i);constmystructx2=*x1;couty)y)y.push_back(4);}好像迭代器返回的是常量对象,不让我

c++ - 复制初始化: why move or copy constructor was not called even if copy-elision is turned off?

我的问题不同,因为我可能“知道”复制省略。我正在学习复制初始化。但是,以下代码让我感到困惑,因为我已经使用-fno-elide-contructors-O0选项关闭了复制省略。#includeusingnamespacestd;classtest{public:test(inta_,intb_):a{a_},b{b_}{}test(consttest&other){cout我首先使用命令构建:g++-std=c++11-fno-elide-constructors-O0main.cpp-omain得到如下结果:**showelideconstructors**moveconstruct

c++ - 错误 : no matching function for call to . .. 在返回语句

我在openSUSELeap15上的Qt5.9.4上使用GCC7。我有以下类(class):classManSuppProps:publicQObject{Q_OBJECTpublic:explicitManSuppProps(QStringparentName);explicitManSuppProps(){}explicitManSuppProps(constManSuppProps&manSuppProps);explicitManSuppProps(ManSuppProps&manSuppProps);~ManSuppProps();private:QVector3Dm_sup

c++ - tr1::mem_fn 和具有默认参数的成员

我有一个带有默认参数的成员函数的类。structClass{voidmember(intn=0){}};通过std::tr1::mem_fn我可以调用它:Classobject;std::tr1::mem_fn(&Class::member)(object,10);就是说,如果我想用默认参数调用对象上的callable成员,正确的语法是什么?std::tr1::mem_fn(&Class::member)(object);//Thisdoesnotworkg++报错如下:test.cc:17:error:nomatchforcallto‘(std::tr1::_Mem_fn)(Clas

c++ - 虚假 "missing sentinel in function call"

如果编译为CandC++源代码,这个简单的代码片段会使用g++4.7.0生成“函数调用中缺少标记”警告。我相信这是编译器的错误,因为最终的NULL值(value)就在那里。#includeintmain(){execlp("mkdir","mkdir","-p","test",NULL);return0;}我说得对吗? 最佳答案 不,你错了。在C++中NULL类似于0或0L并且在C中可能是相同的。如果该常量的类型小于指针那么它是不安全的将其传递给可变参数函数,因为高位将被垃圾填满。在Linux上,execlp(1)手册页说:Thel

c++ - 在 c++ 中的 fn 调用中,args 被复制到相应的参数。这是初始化还是赋值?

在C++中的函数调用中,参数被复制到相应的参数中。这是初始化还是赋值? 最佳答案 参数传递语义是初始化的语义。意思是,您的类的复制/移动构造函数将被调用。 关于c++-在c++中的fn调用中,args被复制到相应的参数。这是初始化还是赋值?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/14737680/

c++ - Qt 信号槽 : Signal is sent but Slot is not called

我在C++的VisualStudio2013中使用Qt。我正在尝试将信号连接到插槽。问题是信号已发送,但槽函数从未被调用,我不知道发生了什么。这段代码之前可以工作,但是在我将代码从32位的VisualStudio2012迁移到64位的VisualStudio2013并进行一些更改后,它不再工作了。它打印调试语句:发送前、发送图像和连接,但不打印接收到的图像。有人可以帮忙吗?Streamer.hsignals://SignaltooutputframetobedisplayedvoidprocessedImageStream(constvector&imgs,constQImage&im

c++ - 海湾合作委员会 "no matching function for call.."错误

我正在开发一个跨平台代码库,其中初始工作是使用MSVC2010编译器完成的。后来我在Linux上使用GCC(4.7)编译它。在许多情况下,我收到:“没有匹配的调用函数..”GCC中的错误。我注意到它主要在方法参数是非常量引用时提示。例如:voidMyClass::DoSomeWork(ObjectSP&sprt,conststd::stringsomeName,conststd::stringanotherName,conststd::stringpath,intindex){sprt->GetProp()->Update(path,false);}一旦我将方法更改为:voidMyCl

C++ 模板 : no matching function for call

考虑以下代码templateTexponentiel(Tval,unsignedn){Tresult=one;unsignedi;for(i=0;i(2.0f,3);cout编译器告诉我这个没有匹配函数来调用'exponentiel(float,int)'为什么?奇怪的是exponentiel与int一起使用。 最佳答案 问题出在模板参数列表中的Tone和1.0上。您不能拥有浮点类型的非类型模板参数,也不能将浮点值作为模板参数传递。这是不允许的(据我所知,没有充分的理由不允许这样做)。g++在这里的错误信息是相当无用的。Visual