草庐IT

non-matching

全部标签

c++ - 警告 : non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]

这个问题在这里已经有了答案:C++ArrayInitializersWarnings(2个答案)关闭8年前。我刚刚在我的机器上安装了最新版本的cygwin和eclipseluna。它工作正常,我能够运行我的项目。但是,当我构建它们时,我收到了我不明白的警告。例如,这是我从“c++Primer”一书的网站上获得的头文件“Sales_item.h”的警告:warning:defaultedanddeletedfunctionsonlyavailablewith-std=c++11or-std=gnu++11[enabledbydefault]Sales_item()=default;^..

c++ - "Control reaches end on non-void function"with do { 返回结果; } 而(条件);

我有以下功能(简化示例):QByteArrayDecompressBytes(constQByteArray&content){/*functionbody(withotherreturnexpressions)*/do{returncontent;}while(content.size()!=0);}添加最后一行用于测试,替换使用的宏。VisualStudio没有发现此代码有问题,但g++生成了warning:controlreachesendofnon-voidfunction[-Wreturn-type]将最后一行更改为returncontent;删除警告。我的问题:为什么编译器

c++ - 从 GCC 得到 "no matching function"

为什么这个简单的代码不起作用?templateclassretype{typedefUtype;};classobject{public:templateintcreate(typenameretype::typep){return4;}};intmain(){intn=object().create(5);return0;}使用GCC编译时出现此错误:test.cpp:Infunction‘intmain()’:test.cpp:20:error:nomatchingfunctionforcallto‘object::create(int)’问题出在哪里?

c++ - 嵌套类声明 : template vs non-template outer class

我有一个C++模板类,里面有一个嵌套类,比如:templateclassOuter_t{public:classInner;Inneri;};templateclassOuter_t::Inner{public:floatx;};intmain(){Outer_to_t;//3oranyarbitraryinto_t.i.x=1.0;return0;}编译没有任何问题。然而,一旦我声明了一个类似的非模板类,就像这样:classOuter_1{public:classInner;Inneri;};classOuter_1::Inner{public:floatx;};intmain(){

c++推导 "non type pointer to function"类模板参数

考虑一个模板类:templateclassProxy{voidrun(){ReturnTyperet=Fn();//...dosomething...}};//andafunctionsintfn1(){return5;}floatfn2(){return5;}这可以通过使用实例化:Proxyp1;但是显式声明返回值类型似乎是不必要的。我想要实现的是:someProxyInstantationp1;someProxyInstantationp2;不幸的是,我对c++没有任何期望,这似乎是该语言的一个隐藏角落(至少对我而言)。如果我可以从指向函数的指针获取它的类型——类似于:std::t

C++ 模板和 "no matching function to call"

我遇到了一个奇怪的错误。我有以下签名的功能:templatestaticboolConvertCbYCrYToRGB(constCharacteristicspace,constDATA*input,DATA*output,constintpixels){后来这样称呼:casekByte:returnConvertCbYCrYToRGB(space,(constU8*)input,(U8*)output,pixels);casekWord:returnConvertCbYCrYToRGB(space,(constU16*)input,(U16*)output,pixels);casek

c++ - begin() 如何知道要返回哪种返回类型(const 或 non-const)?

这非常有效:listl;list::const_iteratorit;it=l.begin();list::iteratorit2;it2=l.begin();我不明白list是怎么来的“知道”它必须返回iteratorbegin()版本或const_iteratorbegin()const一个。我正在尝试为我的容器(一个trie)实现迭代器,但我遇到了这个问题。难道C++不应该不按返回类型处理差异化(除非使用奇怪的技巧)?这是一些代码和我得到的编译器错误:我的Trie是一个模板化的trie,可以包含任何类型。我有一个Trie::iter非常量迭代器和一个Trie::const_ite

c++ - 谷歌模拟 : How to configure custom message to explain match failure

如果匹配失败,Googlemock会打印如下消息:test.cpp:112:EXPECT_CALL(mock_obj,foo(MyMatcher(bar)))...Expectedarg#0:isequalto[1,2;3,4]Actual:{1}Expected:tobecalledonceActual:nevercalled-unsatisfiedandactive使用自定义匹配器MyMatcher我可以定义一个描述字符串,用于在匹配失败时生成失败消息。但它只定义了消息的Expectedarg#0部分。有什么方法可以自定义Actual的打印方式吗?在我的例子中,我不能为bar的类重

c++ - 'non-virtual interface' 和 'abstract interface' 有什么区别?

我正在用C++实现设计模式,我希望我的类通过组合来利用接口(interface),这让我研究了实现接口(interface)的不同方法。我想澄清一下这个术语的定义。 最佳答案 非虚拟接口(interface)是一个公共(public)成员函数,它不是虚拟的,但通常希望根据可覆盖的虚拟函数来实现:classInterface{public:intcompute(){returncompute_impl();}private:virtualintcompute_impl()=0;protected:virtual~Interface()

c++ - 错误 : no instance of overloaded function "std::make_shared" matches the argument list

查看ApreviousstackQuestionstd:make_sharedvsstd::shared_ptr,我试图在一个uni项目中实现它。这是之前的“问题”:Ican'tthinkofanysituationwherestd::shared_ptrobj(newObject("foo",1));wouldbepreferredtoautoobj=std::make_shared("foo",1);因此我采用了这段代码:std::shared_ptrpT1(newTriangle(pCanvas,30,30,30,60,60,30,255,0,0));并将其修改为这段代码:aut