草庐IT

initial_value

全部标签

c++ - 错误 : Element <EnableEnhancedInstructionSet> has an invalid value of "NoExtensions"

我想在虚拟机WindowsXP下VS2010下打开别人的C++项目。问题是,我认为该项目似乎是在Windows7下的VS2012下开发的。我已经成功转换了它的相关配置,感谢互联网。但是现在,当我尝试构建这个项目时,出现了以下错误:C:\ProgramFiles\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(147,5):error:Elementhasaninvalidvalueof"NoExtensions".似乎配置更改导致了这个问题。我所做的是将Project->Properties-

c++ - 错误 C2448 : function-style initializer appears to be a function definition

我有以下一段代码-voidCommandProcessor::ReplacePortTag((void*)portID){std::stringtemp=std::string.empty();intstart=0;for(inti=0;i"){temp+=CommandProcessor::fileContents.substr(start,i-start);temp+=portID;start=i+6;}}temp+=CommandProcessor::fileContents.substr(start+6,CommandProcessor::fileContents.length

c++ - 没有匹配的成员函数来调用 child.value

当我尝试编译下面的代码时出现错误:src/main.cpp:51:48:error:nomatchingmemberfunctionforcallto'child_value'std::cout我不明白的是我能够在上面的循环中使用它。我只能假设它希望我使用kv.second.child_value(kv.second);代替。但是我希望它在for(auto&eb:mapb){.返回的xml上运行这段代码。#include"pugi/pugixml.hpp"#include#include#includeintmain(){conststd::maptagMap{{"descriptio

c++ - "warning C4800: ' int' : forcing value to bool 'true' or 'false' "不同场景下的不同行为

我无法理解此警告的以下行为。case1:boolread=(33&3);//NoWarningissuedbyvs2013case2:intb=33;boolread=(b&3);//NowcompilerisgeneratingC4800warning.为什么编译器在情况2中生成警告,而在情况1中不发出任何警告。 最佳答案 C4800是一个性能警告-在运行时将整数强制转换为bool会产生成本。这与逻辑正确性无关。最常见的强制转换(和警告)发生在您与使用整数(VC++中的BOOL)作为bool值的代码交互时。第一个代码段中的编译时强

c++ - 将 initializer_list 插入 std::vector 时出现 "Invalid iterator range"

此代码在Ideone上按预期编译并运行良好:#include#include#includeintmain(){std::vectorstrVec;strVec.insert(strVec.end(),{L"black",L"white",L"red"});strVec.insert(strVec.end(),{L"blue",L"green"});//STLexceptionfor(auto&i:strVec){std::wcout但是,在MSVC(VisualStudio2013)中因“无效的迭代器范围”而失败。有什么见解吗?顺便说一句,插入更多元素是可行的,例如在第二个插入中,这

c++ - C++初始化中的 "several values"是什么?

这是一道关于C++Primer(5thedition)Chapter3.2,Page84,85的问题。Whenwehaveasingleinitializer,wecanuseeitherthedirectorcopyformofinitialization.Whenweinitializeavariablefrommorethanonevalue,suchasintheinitializationofs4,wemustusethedirectformofinitialization:strings4(10,'c');//s4is"cccccccccc"strings5="hiya";

c++ - 数组与 std::initializer_list 作为函数参数

我可以通过两种方式编写一个将临时数组(例如{1,2,3})作为参数的函数://usingarraytemplateautofoo1(constT(&t)[N])->void;//usingstd::initializer_listtemplateautofoo2(std::initializer_listt)->void;是否有任何指南可以告诉您哪个更好? 最佳答案 它们是完全不同的东西。还有2或3个其他选择是合理的。templatevoidfoo_a(std::arrayconst&);templatevoidfoo_b(gsl:

c++ - QtableWidget : How to find value in specific column

我需要使用qtablewidget检查特定值是否在特定列中。在我的例子中,我需要检查第一列ID是否已经存在,如果是,我需要包含行的编号来更新该行,否则我想添加该行。QT有没有提供查列或者shou的解决方案 最佳答案 我假设您正在寻找第一列中的值(这就是为什么item(int,int)中的第二个参数为0)并且表名是myQTableWidgetintrows=myQTableWidget->rowCount();boolfound=false;for(inti=0;iitem(i,0)->text()=="Something"){//w

c++ - 如何编写模板将 vector 转换为 Json::Value (jsoncpp)

我写了一个模板(如下所示)但是编译失败templateclassiterable>Json::Valueiterable2json(constiterable&cont){Json::Valuev;for(constt&elt:cont){v.append(elt);}returnv;}std::vectorvec{1,2,3};Json::Valuev=iterable2json(vec)错误C3312:找不到类型“conststd::_Vector_val”的可调用“开始”函数与[_Val_types=std::_Simple_types]参见正在编译的函数模板实例化'Json::

c++ - 如何在 C++ 中为不同的迭代器 value_types 重载函数

我想在C++11中实现一个带有一对迭代器的模板函数。如果传递了一对迭代器,其值类型是任意类型的std::pair,则实现应该做一些特殊处理。我试图提出以下定义://arbitraryvaluetypestemplatevoidprocess(Iterbegin,Iterend){for(Iteriter=begin;iter!=end;++iter){std::cout::value_type,std::pair>::value>::type*=0>voidprocess(Iterbegin,Iterend){for(Iteriter=begin;iter!=end;++iter){s