【发布时间】:2020-10-18 16:35:49
【问题描述】:
我有一个指向 std::function 的指针,其中存储了 lambda。
我怎么称呼那个 lambda?
示例:
std::function <void()>* fx = new std::function <void()>([] {std::cout << "Hello world;\n"; });
//here i need to call my fx, just fx(); does not works in this case
fx可以存储在std::pair中
【问题讨论】:
-
(*fx)();但是你为什么使用指向 std::function 的指针。似乎是个糟糕的选择。 -
@super 答案应该出现在答案框中。请...
-
阅读一些good C++ programming 的书并查看this C++ reference。另请阅读 C++ 编译器的文档(可能是 GCC...)。喜欢 smart pointers 而不是原始的
标签: c++ c++11 lambda std-function function-call