草庐IT

member_function

全部标签

c++ - OpenCV GTK+2.x 错误 - "Unspecified error (The function is not implemented...)"

我已经按照这些步骤安装了OpenCV。在尝试编译一个示例后,我得到了这个错误:OpenCVError:Unspecifiederror(Thefunctionisnotimplemented.RebuildthelibrarywithWindows,GTK+2.xorCarbonsupport.IfyouareonUbuntuorDebian,installlibgtk2.0-devandpkg-config,thenre-runcmakeorconfigurescript)incvNamedWindow,file/home/nick/.Apps/opencv/modules/high

c++ - std::function<> 的 vector

说要存储以下内容:typedefstd::functionMyFunctionDecl;..在一个集合中:typedefstd::vectorFunctionVector;FunctionVectorv;这是可能的,但如果我想find使用std::find:FunctionVector::const_iteratorcit=std::find(v.begin(),v.end(),myFunctionDecl);..由于==运算符,我们得到一个错误。正如在上一个问题中向我建议的那样,这可以通过将函数声明封装在另一个类中来解决,该类提供==运算符:classWrapper{private:

c++ - std::function<> 的 vector

说要存储以下内容:typedefstd::functionMyFunctionDecl;..在一个集合中:typedefstd::vectorFunctionVector;FunctionVectorv;这是可能的,但如果我想find使用std::find:FunctionVector::const_iteratorcit=std::find(v.begin(),v.end(),myFunctionDecl);..由于==运算符,我们得到一个错误。正如在上一个问题中向我建议的那样,这可以通过将函数声明封装在另一个类中来解决,该类提供==运算符:classWrapper{private:

c++ - 返回没有 std::function 的 lambda

考虑以下返回lambda的函数:std::functionmake_counter(){inti=0;return[=]()mutable{returni++;};}是否可以返回实际的lambda类型,而不将其包装到std::function中? 最佳答案 C++11:不。每个lambda表达式都有,我引用(§5.1.2/3):[...]aunique,unnamednon-unionclasstype[...]这实际上意味着如果不先知道相应的表达式,就无法知道lambda的类型。现在,如果您没有捕获任何内容,您可以使用转换为函数指

c++ - 返回没有 std::function 的 lambda

考虑以下返回lambda的函数:std::functionmake_counter(){inti=0;return[=]()mutable{returni++;};}是否可以返回实际的lambda类型,而不将其包装到std::function中? 最佳答案 C++11:不。每个lambda表达式都有,我引用(§5.1.2/3):[...]aunique,unnamednon-unionclasstype[...]这实际上意味着如果不先知道相应的表达式,就无法知道lambda的类型。现在,如果您没有捕获任何内容,您可以使用转换为函数指

c++ - 试图理解 "pointer to member"

我试图了解“指向成员的指针”是如何工作的,但对我来说并非一切都清楚。这是一个示例类:classT{public:inta;intb[10];voidfun(){}};以下代码说明问题并包含问题:voidfun(){};voidmain(){Tobj;intlocal;intarr[10];intarrArr[10][10];int*p=&local;//"standard"pointerintT::*p=&T::a;//"pointertomember"+"T::",thatisclearvoid(*pF)()=fun;//herealsoeverythingisclearvoid(T

c++ - 试图理解 "pointer to member"

我试图了解“指向成员的指针”是如何工作的,但对我来说并非一切都清楚。这是一个示例类:classT{public:inta;intb[10];voidfun(){}};以下代码说明问题并包含问题:voidfun(){};voidmain(){Tobj;intlocal;intarr[10];intarrArr[10][10];int*p=&local;//"standard"pointerintT::*p=&T::a;//"pointertomember"+"T::",thatisclearvoid(*pF)()=fun;//herealsoeverythingisclearvoid(T

c++ - 我可以在 std::function 模板签名类型参数中使用命名参数吗?

我可以合法地在std::function(或其他类似结构)中使用模板参数名称吗?例如。给定代码std::functionsome_func;我可以用下面的方式重写吗?std::functionsome_func;如果它符合标准,那就太好了,因为类型本身很少包含有关参数用途的信息。到目前为止,我已经在VisualStudio2013中对其进行了测试,并且可以正常工作。编辑:它也适用于gcc4.8.1。 最佳答案 是的,您可以提供参数名称。来自C++11标准的第8.3.5/11段:Anidentifiercanoptionallybep

c++ - 我可以在 std::function 模板签名类型参数中使用命名参数吗?

我可以合法地在std::function(或其他类似结构)中使用模板参数名称吗?例如。给定代码std::functionsome_func;我可以用下面的方式重写吗?std::functionsome_func;如果它符合标准,那就太好了,因为类型本身很少包含有关参数用途的信息。到目前为止,我已经在VisualStudio2013中对其进行了测试,并且可以正常工作。编辑:它也适用于gcc4.8.1。 最佳答案 是的,您可以提供参数名称。来自C++11标准的第8.3.5/11段:Anidentifiercanoptionallybep

c++ - 为什么没有 std::make_function()?

std::function是几乎所有可调用事物的有用包装器,包括自由函数、lambda、仿函数、成员函数,结果来自std::bind.但是,当创建std::function,必须明确指定函数签名,如(取自here)structFoo{Foo(intnum):num_(num){}voidprint_add(inti)const{std::coutf_display=print_num;//storealambdastd::functionf_display_42=[](){print_num(42);};//storetheresultofacalltostd::bindstd::fu