草庐IT

non-matching

全部标签

c++ - 应该如何使用 const/non-const 参数重载函数?

我有以下代码://stringspecializationsvoidfoo(constchar*a,constchar*b);voidfoo(constchar*a,conststd::string&b);voidfoo(conststd::string&a,constchar*b);voidfoo(conststd::string&a,conststd::string&b);//genericimplementationtemplatevoidfoo(TAa,TAb){...}问题是这个测试用例:chartest[]="test";foo("test",test);最终调用了foo的

c++ - "enumeral and non-enumeral type in conditional expression"背后的推理

自C++11过渡以来,GCC输出警告“条件表达式中的枚举和非枚举类型”。我想了解此警告背后的原因。比较枚举常量有什么危险?很明显我们可以通过以下方式摆脱这个警告-Wno-enum-compare通过显式转换为整数类型但为什么这么麻烦?就个人而言,我一直努力编写无警告代码,通常默认发出的警告是非常合理的。例如,它认为比较有符号和无符号整数是危险的。但是使用枚举是广泛使用的惯用C++元编程。我不知道有任何替代方案,它同样具有可读性、简明扼要且不需要任何实际存储空间。举一个具体的例子:下面的元函数会出现什么问题,以至于警告就足够了?templatestructMaxSize;template

java tor String.Match()用于整数

我正在尝试从我的OCR文本检测器中获取某些数字。到目前为止,我还无法成功提取某种格式的数字。该数字看起来与此5225612832654455相似,通常该格式可能像xxxxxxxxxxxxxxxx我需要一个字符串匹配的正则是获得这样的数字。注意:图源还有其他数字,我需要避免在这里捕获是方法ListtextComponents=text.getComponents();for(TextcurrentText:textComponents){floatleft=translateX(currentText.getBoundingBox().left);floatbottom=translateY(c

c++ - 打印 std::this_thread::get_id() 给出 "thread::id of a non-executing thread"?

这曾经工作得很好(然后外星人一定黑了我的电脑):#include#includeintmain(){std::cout现在它打印thread::idofanon-executingthread。ideone.com打印了一些ID,但有趣的是是什么导致了我平台上的这种行为。$uname-aLinuxxxx3.13.0-77-generic#121-UbuntuSMPWedJan2010:50:42UTC2016x86_64x86_64x86_64GNU/Linux有什么想法吗?编辑:嗯..当我添加std::cout两行打印相同的ID,但是当我删除它时,结果仍然相同-“非执行线程”。

c++ - 我们可以使用异构查找比较器对 STL 关联容器执行 "partial-match"搜索吗?

所以我在STL的关联容器(自C++14起)中寻找对异构查找的支持,并对我们可以做什么和不应该做什么感到有点困惑。以下片段#include#include#includestructpartial_compare:std::less{//"full"key_typecomparisondonebystd::lessusingless::operator();//"sequence-partitioning"comparison:onlycheckpair'sfirstmemberbooloperator()(std::pairconst&lhs,intrhs)const{returnlh

c++ - 前向声明的类型和 "non-class type as already been declared as a class type"

我对以下代码有疑问:templatevoidfoo(structbar&b);structbar{};intmain(){}它在GCC上编译成功,但在MSVC(2008)上编译失败并出现以下错误:C2990:“bar”:已声明为类类型的非类类型是代码错误还是MSVC中的错误?如果我在模板定义之前添加structbar;就可以了。 最佳答案 我们有我们的赢家:https://connect.microsoft.com/VisualStudio/feedback/details/668430/forward-declared-type-

解决kubelet报failed to get imageFs info: non-existent label \“docker-images\“

问题:一环境主机重启后,查看kubelet日志经常有大量无法回收镜像文件报错,会导致kubelet的pleg不健康,从而导致kubelet发生重启。报错如下:解决办法解决方法一:systemctlstopdockersystemctlstopkubeletsystemctlstartdockersystemctlstartkubelet解决方法二:在kubelet的kubelet.service文件中,添加如下参数:[Unit]After=docker.service原因总结:主机重启后,kubelet比docker先启动,会对不健康的pod进行一个资源回收的过程,这个时候docker还没正常

c++ - STL 中的 VS 编译器错误 C2752 ("more than one partial specialization matches")

不知何故,我喜欢这些显示(基本?)问题的“最短”程序。在VS2008中测试一些模板代码时出现了这个错误(它也已在VS2010和VS2012中得到确认,见下文):c:\programfiles(x86)\microsoftvisualstudio9.0\vc\include\xmemory(225):errorC2752:'std::_Ptr_cat_helper':morethanonepartialspecializationmatchesthetemplateargumentlistwith[_T1=constfloat(**),_T2=constfloat(**)]我可以将问题归

C++ - 错误 E2285 : Could not find a match for 'tolower(char *)' in function parseInput(fstream &)

给定以下代码:voidparseInput(fstream&inputFile){constintLENGTH=81;charline[LENGTH];while(!inputFile.fail()){inputFile.getline(line,LENGTH);line=tolower(line);cout编译时出现这个错误:ErrorE2285:Couldnotfindamatchfor'tolower(char*)'infunctionparseInput(fstream&)我知道它返回一个int,而不是int[],这是否意味着我不应该使用getline而应该将输入字符转换为字符

c++ - 成员函数的部分模板特化 : "prototype does not match"

我正在尝试部分特化一个非模板化类的模板化成员函数:#includetemplateclassFoo{};structBar{templateintfct(T);};templateintBar::fct(Foo){}intmain(){Barbar;Fooarg;std::cout我收到以下错误:c.cc:14:error:prototypefor‘intBar::fct(Foo)’doesnotmatchanyinclass‘Bar’c.cc:9:error:candidateis:templateintBar::fct(T)如何修复编译器错误? 最佳答案