草庐IT

get_argument

全部标签

c++ - 对 C++ 中的 std::get_money 和 std::put_money 的混淆

我对C++函数感到困惑std::get_money在中定义头文件。get_money有什么用根据编程概念?我有以下代码使用std::get_money.#include//std::cin,std::cout#include//std::get_moneyintmain(){longdoubleprice;std::cout>std::get_money(price);if(std::cin.fail())std::cout当我输入100.25时,它返回100。输出和货币格式之间有什么关系?我读了this引用但无法理解关系。std::put_money也存在同样的混淆。,std::ge

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++ - 使用派生自 `std::get` 的元素在 `std::tuple` 上调用 `std::tuple` - 格式错误?

structY{};structX:std::tuple{};intmain(){std::get(std::make_tuple(X{}));}onwandbox当使用libc++时,上面的代码可以通过clang++编译并按预期工作。当使用libstdc++时,上述代码无法同时使用clang++和g++进行编译,并出现以下错误:include/c++/7.0.1/tuple:1302:36:error:nomatchingfunctionforcallto‘__get_helper(std::tuple&)’{returnstd::__get_helper(__t);}~~~~~~~

c++ - 为什么这个 get_index 实现在 VS2017 上失败了?

巴里给了我们thisgorgeousget_indexforvariants:templatestructtag{};templatestructget_index;templatestructget_index>:std::integral_constant...>(tag()).index()>{};按如下方式使用:usingV=variant;constexprconstsize_tN=get_index::value;//1它在Clang(OSX)中运行良好。但在VisualStudio2017中I'mgetting以下内容:(10):errorC2039:'index':is

php:file_get_contents不起作用

我有此代码://Aif(condition1){//Bif(condition2){//C}}和file_get_contents($url)。我希望此file_get_contents在“//c”中运行,但是我注意到了这一点:在适当的作品中,但是如果放入“//b”或“//c”,则相同的指令,不起作用,并且“不起作用,”条件1“和“条件2”都经过验证(将其他仪器放入b或c时,它们起作用)。我还尝试了此尝试/捕获声明,但没有成功:try{$content=file_get_contents($url);if($content===false){//THISisalwaysverified}}ca

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++ - STL 容器 move 语义并按值返回 : how many times of copying get avoided away?

我知道在C++11中,move语义已经在STL容器中实现以避免临时对象。人们说现在编写按值返回的函数是完美的。但我对究竟有多少次复制实际上被避免感到困惑。请看下面的例子:vectormyVector(){vectorres;res.push_back(4);res.push_back(5);returnres;}vectorv=myVector();我的理解是在c++03中,myVector返回res的拷贝(4,5复制了一次),在评估vectorv=myVector();时vector的复制构造函数vector(constvector&)被调用(4,5复制了两次)。但是在具有move语

c++ - 尝试使用 std::get_time 解析 YYMMDD 并失败

我正在尝试这样做但失败了:std::istringstreamss("1212");ss>>std::get_time(&t,"%y%m");if(ss.fail())//everytime!这工作正常:std::istringstreamss("12-12");ss>>std::get_time(&t,"%y-%m");知道我做错了什么吗?我还能用什么,因为Windows似乎没有srtptimewindow/vs13时间差 最佳答案 VisualStudio似乎没有正确实现规范,GCCuntilversion5.0也没有。.如果您

c++ - OSG : Get transform matrix from a node

首先,我必须为我的英语道歉。我正在开发一个应用程序,我们必须在每个时刻知道每个节点的属性(位置、旋转...),所以我考虑从场景图中获取每个节点的变换矩阵。我遇到的问题是我不知道该怎么做。例如,如果我有这样的东西:osg::ref_ptrroot=osgDB::readNodeFile("cessna.osg.15,20,25.trans.180,90,360.rot.2,3,4.scale");我想从名为root的Node对象中获取变换矩阵。我发现了类似的东西:osg::Matrixmat=osg::computeWorldToLocal(this->getNodePath());st

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