jjzjj

Parameter

全部标签

c++ - Uncrustify 拆分函数调用参数

我想像这样格式化代码:a)线宽最大120b)-如果调用函数的长度>120,则函数调用参数每行一个,缩进else函数调用在一行中c)-如果函数调用在if、for、while等中......参数的格式应如b)我有代码(这只是一个虚构的):voida_function(){if(verify_if_the_conditions_are_meet(first_parameter,second_parameter,third_parameter,fourth_parameter,fifth_parameter,sixth_parameter)){call_a_function_with_many

c++ - C++ 模板的部分特化 : template parameter not deducible

下面的代码工作正常:templateclassFib{};templateclassFib{};但是下面的代码显示错误为:Error:templateparametersnotdeducibleinpartialspecialization:templateclassFib{};templateclassFib{};你能解释一下这种行为的原因吗? 最佳答案 我相信您只是缺少部分特化的正确语法:templateclassFib{};templateclassFib{};模板上的第一个参数是类型,而第二个只是一个常量值。

c++ - 视觉 C++ :error C2664: 'GetModuleFileNameW' : cannot convert parameter 2 from 'char [260]' to 'LPWCH'

当我尝试编译我的项目时,我遇到了一些我无法解决的错误。无论如何这是代码之一:public:voidInit(HMODULEhModule,stringFilename){charszLoc[MAX_PATH];GetModuleFileName(hModule,szLoc,sizeof(szLoc));char*dwLetterAddress=strrchr(szLoc,'\\');*(dwLetterAddress+1)=0;strcat(szLoc,Filename.c_str());__OutStream.open(szLoc,ios::app);}错误是:errorC2664:

c++ - 部分模板特化取决于混合类型的整数常量的可变参数包

假设需要部分特化一个模板类型,该模板类型需要一个可变类型列表,用于所有参数都是特化的情况,比如说,std::integral_constant。以下直接的方法被各种版本的clang和GCC接受,但被VS14(2015)拒绝并出现错误:errorC3522:'t':parameterpackcannotbeexpandedinthiscontexttemplatestructfoo;templatestructfoo...>{/*...*/};foo,std::true_type>bar;我似乎无法在C++标准草案(n4296)中找到任何明确允许或禁止此类模式匹配的内容,因此在我提交针对

c++ - 可变参数模板 : Pass parameter pack without expansion

旧的Cstdio工具提供了一种使用vprintf工具传递可变参数集的方法。是否有类似的方式来传递C++0x可变模板参数包而不扩展它?如果您有一个采用可变参数模板参数包的派生类构造函数,并且需要简单地将其传递给基类构造函数,而不是将其解包,这可能会很有用。例如:templateBase::Base(constT&v,constArgs&...args){/*...expandargshere....*/}templateDerived::Derived(constT&v,constArgs&...args):Base(v,args){/*...don'texpandargs...*/}我

c++ - yaml-cpp 0.5.1 的可选 key

Apreviousanswer描述了如何使用YAML::Node::FindValue("parameter")检查yaml节点中是否存在键。不幸的是,我不能在最新版本(0.5.1)中调用它:error:‘classYAML::Node’hasnomembernamed‘FindValue’这是预期的工作还是有一个等效的功能可以在最新版本中工作? 最佳答案 在新的API中,您可以检查:if(node["parameter"]){//...}在if(...)block中定义一个对象可能很方便:if(YAML::Nodeparamete

c++ - VS2012 "Generating Code"大型硬编码数组速度慢

我们有一个工具可以在头文件中生成一个类,该文件是用硬编码数组生成的。自动生成的值由使用自动生成值的实际实现继承。自动生成的示例:classMyTestAutoGen{std::vectorm_my_parameter1;std::vectorm_my_parameter2;...public:MyTestAutoGen(){SetDefaultValueFor_my_parameter1();SetDefaultValueFor_my_parameter2();...}voidSetDefaultValueFor_my_parameter1(){inttmp[]={121,221,33

c++ - cmake -D <变量> :<type>=<value> what does the parameter "-D" mean

我正在尝试使用cmake安装opencv。在opencv说明页面中,我找到以下示例:cd~/opencvmkdirreleasecdreleasecmake-DCMAKE_BUILD_TYPE=RELEASE-DCMAKE_INSTALL_PREFIX=/usr/local..据我了解,我应该在我创建的新目录中使用cmake生成Makefile,在这个例子中应该是~/opencv/release。但我不太明白最后一行。在cmake帮助中,我发现:cmake-D:==createacmakecacheentry这是什么意思?特别是这部分:":=",我不明白为什么这个例子给出了"CMAKE

c++ - 继承的构造函数不工作 | C++

我的基类位于Employee.h中,这是构造函数的代码。Employee(stringFname="FirstNamenotSet.",stringLname="LastNamenotSet.");这是Employee.cpp的代码Employee::Employee(stringFname="FirstNamenotSet.",stringLname="LastNamenotSet."):FirstName(Fname),LastName(Lname){}问题出在我的两个构造函数上,它说它们的参数有误,但我不确定它们出了什么问题。经理.hclassManager:publicEmpl

c++ - const 或 ref 或 const ref 或 value 作为 setter 函数的参数

恒常性classMyClass{//...private:std::stringm_parameter;//...}按值传递:voidMyClass::SetParameter(std::stringparameter){m_parameter=parameter;}通过引用:voidMyClass::SetParameter(std::string¶meter){m_parameter=parameter;}通过常量引用:voidMyClass::SetParameter(conststd::string¶meter){m_parameter=parameter;}按