草庐IT

argument2

全部标签

c++ - 默认模板参数 : Why does the compiler complain about not specifying template argument?

我有这个代码:structA{};templatestructB{voidfoo(){}};Bb;//Error:missingtemplateargumentsbefore'b'//Error:expected';'before'b'//Moreerrorsb.foo()如果我将foo()作为具有相同模板“签名”的模板函数,编译器不会提示没有指定模板参数:structA{};structB{templatevoidfoo(){}};Bb;//OKb.foo()那么为什么我需要为带有默认参数的模板类指定参数,而不是为模板函数指定参数呢?我是否遗漏了一些微妙之处?原因肯定是因为模板参数推

java - "projections are not allowed for immediate arguments of a supertype"Kotlin Android Studio

当我将Java转换为Kotlin时出现此错误:JavapublicclassHeaderTabextendsExpandableGroup{privateStringheader;publicHeaderTab(Stringtitle,Listitems){super(title,items);}}KotlinclassHeaderTab(title:String,items:List):ExpandableGroup(title,items){privatevalheader:String?=null}AndroidStudio是这样说的:projectionsarenotallow

java - "projections are not allowed for immediate arguments of a supertype"Kotlin Android Studio

当我将Java转换为Kotlin时出现此错误:JavapublicclassHeaderTabextendsExpandableGroup{privateStringheader;publicHeaderTab(Stringtitle,Listitems){super(title,items);}}KotlinclassHeaderTab(title:String,items:List):ExpandableGroup(title,items){privatevalheader:String?=null}AndroidStudio是这样说的:projectionsarenotallow

c++ - "Invalid template argument"错误在 Visual Studio 但不是 GCC

假设你有代码templateclassBaseType>classEST16:publicBaseType{public:EST16(doubled){}};templateclassSCEST{Ty;};typedefEST16EST16_SC;classChild:publicEST16_SC{public:Child():EST16_SC(1.0){}};classNotWorkingChild:publicEST16{public:NotWorkingChild():EST16(1.0){}};TEST(TemplateTest,TestInstantiate){Childch

c++ - connect() 返回 "invalid argument"和 ipv6 地址

我有这个简单的客户端-服务器应用程序对。代码非常简单,我只使用新的建议方法,如getaddinfo等,一切都适用于ipv4。即使对于ipv6环回(::1)它也有效。当涉及到其他一些ipv6地址时,问题就开始了……我在一个网络中有两台机器,当我传递它们的ipv4地址时一切正常,但是当我给我的客户端ipv6地址时,我在连接函数上遇到错误:参数无效.嘿,我不是已经知道了吗?我愿意!当我尝试ping6这个ipv6地址时,我得到了同样的错误:connect:Invalidargument但是有一种方法可以克服这个障碍-应该选择一个带有-I开关的接口(interface),从那时起一切都可以顺利运

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