【发布时间】:2013-02-15 14:30:10
【问题描述】:
来自 boost::bind 文档(http://www.boost.org/doc/libs/1_53_0/libs/bind/bind.html#with_functions),“bind 接受的参数由返回的函数对象在内部复制和保存”,但如果有办法我可以在这些函数对象中复制参数?
即:
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <string>
using namespace std;
void doSomthing(std::string str)
{
}
int main()
{
boost::function<void(void)> func_obj = boost::bind(&doSomthing, "some string");
//how can I get the std::string argument("some string") through func_obj?
}
提前致谢。
【问题讨论】:
-
你的意思是你想从你的 func_objc 变量中读取它们?不太可能。
-
是的,我就是这个意思。
-
我们现在有 boost 1. 53,而不是 1.35。
-
抱歉,只是解决这个问题,但并不重要。
标签: c++ boost boost-bind boost-function