草庐IT

keyword-argument

全部标签

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++ - 铿锵错误 : non-type template argument refers to function that does not have linkage -- bug?

我有一些非常简单的(C++11)代码,最新的clang(version3.4trunk187493)无法编译,但GCC编译正常。代码(下面)实例化函数模板foo使用局部函数类型Bar然后尝试将其地址用作类模板Func的非类型模板参数:templatestructFunc{};templateexterninlinevoidfoo(){usingFoo=Func>;}intmain(){structBar{};//function-localtypefoo();return0;}clang发出以下错误:error:non-typetemplateargumentreferstofunct

c++ - 错误 C2064 : term does not evaluate to a function taking 0 arguments

各位!我在一个map容器中维护一组channel数据,从中可以通过channel名称访问单个channel数据。对此,我写了一个简单的函数GetIRChannelData(请看下面的代码)。编译时,语句pusIRChannelData=cit->second();抛出错误,显示为errorC2064:termdoesnotevaluatetoafunctiontaking0arguments所有要做的功能就是在map容器中搜索给定的channel名称/ID,如果找到则将其数据指针分配给时间指针。你能告诉我哪里出了问题吗?constArray2D*GetIRChannelData(std

c++ - 模板参数不明确 : could not deduce template argument

我正在做一些看起来像这样的包装器:#includetemplatevoidApply(void(T::*cb)(Value),T*obj,Valuev){(obj->*cb)(v);}classFoo{public:voidMyFunc(constint&i){std::cout我收到这个错误:应用:未找到匹配的重载函数。voidApply(void(__thiscallT::*)(Value),T*,Value):模板参数Value不明确,可能是int或constint&。voidApply(void(__thiscallT::*)(Value),T*,Value):无法从const

c++ - 重载 operator== 提示 'must take exactly one argument'

我试图重载operator==,但编译器抛出以下错误:‘boolRationalnumber::operator==(Rationalnumber,Rationalnumber)’musttakeexactlyoneargument我的一小段代码如下:boolRationalnumber::operator==(Rationalnumberl,Rationalnumberr){returnl.numerator()*r.denominator()==l.denominator()*r.numerator();}声明:booloperator==(Rationalnumberl,Rati

C++ "error: passing ' const std::map<int, std::basic_string<char>>' as ' this' argument of ..."

使用以下代码(为简洁起见摘录):颜色.h:classcolor{public:color();enumcolorType{black,blue,green,cyan,red,magenta,brown,lightgray,nocolor};colorTypegetColorType();voidsetColorType(colorTypecColortype);stringgetColorText()const;private:colorTypecColortype=nocolor;mapcolors={{black,"black"},{blue,"blue"},{green,"gre

c++ - 有没有办法防止 "keyword"在 MS Visual Studio 中突出显示语法

MSVisualStudio编辑器将一些非关键字标识符突出显示为关键字在C++文件中。特别是“事件”和“数组”被视为关键字。这对我来说很烦人,因为它们不是C++关键字。我知道如何将自己的关键字添加到语法高亮标识符列表中,但是如何删除现有的内置的?我知道这可能需要修补一些可执行文件。那么有人知道如何做到这一点吗? 最佳答案 感谢SteveGuidi提到的文章,我能够找到包含Colorizer和IScanner类的可执行文件。它名为vcpkg.dll,位于/MicrosoftVisualStudio8/VC/vcpackages中。(我

c++ - 我可以在编译时检测到 "function arguments"是编译时常量吗

我可以在编译时检测“函数参数”1是否是编译时常量吗?例如,函数print(inti)如果调用print(5)可以打印"constant5"但是"non-constant5"如果作为print(i)调用,其中i是一些非常量变量。特别是,在“isconstant”分支中,我应该能够将i视为constexpr,包括将其用于模板参数等。宏技巧、模板元编程和SFINAE技巧都可以。理想情况下它是可移植的,但特定于编译器的解决方案总比没有好。如果存在“假阴性”也没关系-即,如果常量值有时被检测为非常量(例如,当某些优化被禁用时)。如果解决方案可以检测到常量值何时被间接传递给函数(例如,当常量值被传

C++类模板是模板: template argument is invalid

我的类模板有问题。我希望类中的私有(private)数据是某种数字类型的vectorvector,即:std::vector>std::vector>>但我想要vector类型(我正在使用第三方vector库和STLvector),以及要模板化的元素类型。我尝试了模板模板,但现在我认为这不能解决我的问题。一个高度简化的例子是:#include#includetemplateclassFred{std::vectordata_;};intmain(){Fred>works;//Fred>doesnt_work;return0;}如图所示,它编译得很好,但如果我取消注释main中的第二行,

Windows 程序 : How to snoop on command line arguments?

我正在尝试对基于商业Windows的IDE的构建系统进行逆向工程,因此我可以使用make来构建我的项目。启动了一个程序来执行任务,我需要知道在运行时向该程序传递了哪些命令行参数。然而,Windows进程查看器不显示命令行参数。有什么方法可以查看程序启动时传递的命令行参数吗?(实际上我只是想到我应该用一个stub程序来读取命令行参数。不过,我想知道是否有简单的方法)。 最佳答案 SysinternalsProcessExplorer让你这样做。 关于Windows程序:Howtosnoop