比如我想使用一个存放可调用对象的容器,可以同时容纳匿名函数,仿函数,函数指针和std::function,如何实现呢?
认证0级讲师
You just use std::function to wrap it up. As long as the call signatures of these anonymous functions, functors, function pointers and the like are the same, you can use std::function to save them and put them in a container. .
Use Boost.Any, a generic containerhttp://www.boost.org/doc/libs/1_57_0/doc/html/any.html
You just use std::function to wrap it up. As long as the call signatures of these anonymous functions, functors, function pointers and the like are the same, you can use std::function to save them and put them in a container. .
Use Boost.Any, a generic container
http://www.boost.org/doc/libs/1_57_0/doc/html/any.html