草庐IT

function-point-languages-table

全部标签

c++ - 从编译时已知的日历日期创建 `std::chrono::time_point`

This答案显示了如何将字符串解析为std::chrono::time_point,如下所示:std::tmtm={};std::stringstreamss("Jan9201412:35:34");ss>>std::get_time(&tm,"%b%d%Y%H:%M:%S");autotp=std::chrono::system_clock::from_time_t(std::mktime(&tm));如果我想从一个(公历)日历日期创建一个std::chrono::time_point,其年、月和日在编译时已知,是否有任何比上面建议的从字符串解析它更简单的方法?

C++ 模板 : no matching function for call

考虑以下代码templateTexponentiel(Tval,unsignedn){Tresult=one;unsignedi;for(i=0;i(2.0f,3);cout编译器告诉我这个没有匹配函数来调用'exponentiel(float,int)'为什么?奇怪的是exponentiel与int一起使用。 最佳答案 问题出在模板参数列表中的Tone和1.0上。您不能拥有浮点类型的非类型模板参数,也不能将浮点值作为模板参数传递。这是不允许的(据我所知,没有充分的理由不允许这样做)。g++在这里的错误信息是相当无用的。Visual

c++ - g++ "declaration of "运算符<<"as non-function"

我们有一个自定义的Logging类,它在VisualStudio2010中编译良好,但在Linux上使用g++编译时会抛出错误。我们收到的错误消息如下:Logger.hpp:84:error:declarationof"operator各自的代码行如下:/*:84*/inlineLogger&operatoroutput){if(this->loggingEnabled())std::coutoutput){if(this->loggingEnabled())std::cout>&(*StdEndl)(std::basic_ostream>&);inlineLogger&operato

C++ 初学者 : what is the point of using a variable by reference if using "const"?

我想知道这个函数声明中的逻辑:CMyException(conststd::string&Libelle=std::string(),...按引用使用变量有什么意义?通常,只要变量可能在内部被修改,您就会通过引用传递一个变量...因此,如果您使用关键字const,这意味着它永远不会被修改。这是矛盾的。谁能给我解释一下? 最佳答案 实际上引用是用来避免不必要的对象拷贝。现在,要理解为什么使用const,试试这个:std::string&x=std::string();//error编译会报错。这是因为表达式std::string()创

c++ - emacs - 如果函数包含在命名空间中 (C++),则 "go to beginning of the function"不起作用

在emacs中,我使用C-M-a和C-M-e来开始/结束C++代码中的函数。但是,如果函数包含在命名空间中(它只是跳转到命名空间封装的开头或结尾),则此功能不再有效。有人对此有好的解决方案吗? 最佳答案 这是一个已知错误。它已在Emacs24.1中得到修复,即releasedthreedaysago.得到它。不幸的是,该修复程序从未向后移植,并且不太可能很快发生。 关于c++-emacs-如果函数包含在命名空间中(C++),则"gotobeginningofthefunction"不起作

c++ - 为什么 std::function 在这种情况下不起作用?

假设我有一个类型:structmy_type{doubleoperator()(inta){return3.1415;}};然后我想将它包装在std::function中。考虑两种不同的方法:my_typem_t;std::functionf(std::move(m_t));std::cout一切如我所料,打印出了PI的第一位数字。然后第二种方法:std::functionff(my_type());std::cout在我看来,这段代码与第一个代码绝对相同。rvalue作为参数传递给function包装器。但问题是,第二个代码无法编译!我真的不知道为什么会这样。

c++ - std::tr1::function 和 std::tr1::bind

我在C++类中使用非常复杂的C函数时遇到问题(重写C函数不是一个选项)。C函数:typedefvoid(*integrand)(unsignedndim,constdouble*x,void*fdata,unsignedfdim,double*fval);//Thisone:intadapt_integrate(unsignedfdim,integrandf,void*fdata,unsigneddim,constdouble*xmin,constdouble*xmax,unsignedmaxEval,doublereqAbsError,doublereqRelError,double

c++ - 从结构中调用 Pointer-to-Member-Function 指向的函数

我有一个具有特殊数据结构的类Test。Test类的成员是std::map,其中键是std::string,映射值是struct定义如下:typedefstruct{void(Test::*f)(void)const;}pmf_t;map初始化正常。问题是当我试图调用指向的函数时。我编了一个重现问题的玩具示例。在这里:#include#includeusingnamespacestd;classTest;typedefvoid(Test::*F)(void)const;typedefstruct{Ff;}pmf_t;classTest{public:Test(){pmf_tpmf={&T

c++ - clang++ (3.3/Xcode) 中 std::function 的定义在哪里

问题已解决=>看到最后的更新我正在尝试使用std::function但看起来只包括不提供定义。我试图编译以下代码:#includestd::functionf=nullptr;以c++11作为编译选项:%clang++-c-std=c++11t.cc原因:t.cc:3:6:error:notypenamed'function'innamespace'std'std::functionf=nullptr;~~~~~^t.cc:3:14:error:expectedunqualified-idstd::functionf=nullptr;^2errorsgenerated.我错过了什么?我

c++ - C++ 模板是否能够从父类获取 "forward any class function"?

classFoo{public:voidmethodA();};classManagedFoo{FoofooInst;public:voidmethodA(){doSomething();fooInst.methodA();}};现在我想把ManagedFoo做成一个模板,管理任何类而不仅仅是Foo,并且在调用Foo的任何函数之前,先调用doSomething。templateclassManager{_TyManaged_managedInst;voiddoSomething();public:/*Forwardeveryfunctioncalledby_managedInst*//