草庐IT

some_argument

全部标签

c++ - 构造函数中的奇怪 "candidate expects 1 argument, 0 provided"

我正在用C++制作一个简单的线程服务器应用程序,事实上,我使用libconfig++来解析我的配置文件。好吧,libconfig不支持多线程,因此我使用两个包装类来完成“支持”。重点是,其中一个失败了:classapp_config{friendclassapp_config_lock;public:app_config(char*file):cfg(newlibconfig::Config()),mutex(newboost::mutex()){cfg->readFile(file);}private:boost::shared_ptrcfg;boost::shared_ptrmut

c++ - Arduino:命令 Serial.print ("some string text") 是否占用 SRAM?

我有一个相当大的Arduino项目(在eclipse中)使用Serial.print("somestringtext")命令进行大量调试消息,以便我可以一路调试。我注意到的一件事是我达到了项目中可以拥有的这些数量的限制。如果我放太多,程序会在非常奇怪的地方停止。即:通常在我最新添加的打印命令应该执行之前很久。目前我的项目.hex文件大约有20k。ArduinoUno限制在30kb左右,对吗?所以它不应该太大。所以我觉得实际的问题可能是这些串行命令正在填满我的sram。这只是2kb。我正在使用很多库。命令Serial.print("somestringtext")是否占用SRAM?gcc

c++ - enable_if : minimal example for void member function with no arguments

我试图更好地理解C++11中的std::enable_if并且一直在尝试编写一个最小的示例:一个类A带有成员函数voidfoo()根据类模板中的类型T具有不同的实现。下面的代码给出了期望的结果,但我还没有完全理解它。为什么版本V2有效,但V1无效?为什么需要“冗余”类型U?#include#includetemplateclassA{public:A(Tx):a_(x){}//EnablethisfunctionifT==int/*V1*///template::value,int>::type=0>/*V2*/template::value,int>::type=0>voidfoo(

c++ - "could not convert template argument"指针参数错误,即使使用强制转换

假设我有一个声明如下的模板类:templatestructy{int*b;y(){b=x;}}我确实需要模板参数是一个常量内存地址——它是一个嵌入式代码。如果我尝试像这样实例化它:(编译器是带有-std=gnu++11的gcc4.8.1)yc;我会收到错误消息“无法将模板参数‘1’转换为‘int*’”,这没关系,而且符合标准。我明白。我的问题是转换为指针也不起作用:yd;y(1)>e;error:couldnotconverttemplateargument'1u'to'int*'在这两种情况下。这是为什么?模板参数已经转换,不是吗? 最佳答案

c++ - 当 std::stringstream 使用 ("some content"构造时,tellg() 的预期行为是什么,std::ios::in|std::ios::ate)?

我有以下令我惊讶的代码(使用libstdc++4.8)...#include#include#includeusingnamespacestd;intmain(){std::strings("somecontent");std::stringstreamss(s,std::ios::in|std::ios::ate);std::istream&file=ss;//ss.clear();Makesnodifference...std::cout...具有以下输出。tellg()pos:0此行为与使用std::ifstream(std::ios::ate)时不同。此行为是否正确/符合预期?

c++ - 在抛出 'std::invalid_argument' what() : stoi 实例后终止调用

stoi函数使程序崩溃并显示错误消息"****@****:~>g++-std=c++0xm1.cppstimulation.hstims.hTask.hexoskeleton.hARAIG_Sensors.hProfile.hARAIG_Sensors.h:1:9:warning:#pragmaonceinmainfile[enabledbydefault]Profile.h:1:9:warning:#pragmaonceinmainfile[enabledbydefault]*****@****:~>a.outStimulationConfig.csvTaskConfiguratio

c++ - OpenMp 任务 : can't pass argument by reference

g++-fopenmpmain.cpp提示未定义对std::vector的引用。如何解决这个问题?我已经在Ubuntu上安装了libomp-dev包。主要.cpp#include#includetemplateTrecursiveSumBody(std::vector&vec){Tsum=0;#pragmaomptaskshared(sum){sum=recursiveSumBody(vec);}returnvec[0];}intmain(){std::vectora;recursiveSumBody(a);return0;}undefinedreference/tmp/ccTDECN

c++ - Qt - 获取 "warning: format not a string literal and no format arguments"

在这样的行上不断收到警告qDebug("Anerroroccuredwhiletryingtocreatefolder"+workdir.toAscii());workdir是QString()warning:formatnotastringliteralandnoformatarguments 最佳答案 大概应该是:qDebug("Anerroroccuredwhiletryingtocreatefolder%s",workdir.constData());自qDebug将constchar*作为第一个参数。

c++ - Boost::asio async_write_some 与 async_send

我刚才才注意到boost::asio中的async_write_some和async_send(第二次重载)函数是完全一样的:async_write_some定义:...templateBOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,void(boost::system::error_code,std::size_t))async_write_some(constConstBufferSequence&buffers,BOOST_ASIO_MOVE_ARG(WriteHandler)handler){//Ifyougetanerroronthefo

c++ - 奇怪的 "Could not deduce template argument for ' T'"错误

错误在this代码://myutil.htemplateTConditionalInput(LPSTRinputMessage,LPSTRerrorMessage,predicatecondition);//myutil.cpptemplateTConditionalInput(LPSTRinputMessage,LPSTRerrorMessage,Predcondition){Tinputcout>input;while(!condition(input)){cout>input;}returninput;}...//c_main.cppintrow;row=ConditionalI