Suppose I have method:
void foo(const std::string& s);
Can I create boost::function:
boost::function<void(const std::string&)> f = boost::bind(foo, temp);
where temp is char* that is deleted before f
is called.
Suppose I have method:
void foo(const std::string& s);
Can I create boost::function:
boost::function<void(const std::string&)> f = boost::bind(foo, temp);
where temp is char* that is deleted before f
is called.
Yes. Bind cannot know that the char* can be held in a string, or that it is being passed to a string. To circumvent this, use:
So that your temp is copied into the binder as a string.