继承自 std::函数、语法和用法
inherit from std::function, syntax and usage?
我不明白函子从 std::function 继承时的语法:
class do_sth : public function< any_type (another_type) >
{
bool operator() (string s) {...}
};
我应该使用什么作为any_type和another_type?你能给我一个从 std::function 继承的有益用法的例子吗,因为我还没有理解它?
您应该将operator ()
的返回类型用于any_type
,将参数类型用于another_type
。那么至少它适合。
但实际上,std::function
并不意味着要继承,这样做可能是一个坏主意。
相关文章:
- 1d 智能指针不适用于语法 (*)++
- 助记符和指向成员语法的指针
- 有人能分解一下这个c++模板的语法吗
- C++避免重复声明的语法是什么
- QMetaObject invokeMethod的基于函数指针的语法
- 这个指针在c++中的用法
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 为什么包含windows.h会产生语法错误,从而阻止类的实例化?(C2146,C2065)
- 当C++中需要自动删除时,这是静态的正确用法吗?
- 单独定义模板化嵌套类方法的正确语法
- libstdc++ 文件系统中未初始化的用法?
- 共享指针和具有自定义删除程序的唯一指针之间的语法差异背后的任何原因
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- 复制和交换习惯用法与移动操作之间的交互
- 为什么我会收到错误 C2143 语法错误:缺少"*"之前的';'?
- 奇怪的代码抛出编译错误模板< J,int aSize=10> C2143:语法错误:在"<"之前缺少";"
- C#泛型委托的C++等效语法,以及lambdas的用法
- 继承自 std::函数、语法和用法
- c++中逗号操作符的语法用法
- 从语法的角度来看,"volatile"关键字在C++函数中有多少用法?