在C++中如何使用多态的容器?
PHP中文网
PHP中文网 2017-04-17 11:46:30
0
2
535

比如我想使用一个存放可调用对象的容器,可以同时容纳匿名函数,仿函数,函数指针和std::function,如何实现呢?

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
大家讲道理

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template