
Hello,
Igor R
function
f = boost::bind(echo, s.c_str()); The expression x.c_str() returns a pointer that becomes invalid as soon as any non-const member function of std::string is called for x.
I know reason behind. But use is right to think "I've bind >>abc<<.
Binder should store it and use on f() invocation".
In real code the situation could be even worse - if f can be stored
for future use and invoked when s has already been destroyed.
Passing string instead of const char* behaves exactly how expected
void echo2(const string& s) {
cout << s << '\n';
}
int main() {
string s2 = "abc";
function
_______________________________________________ Boost-users mailing list Boost-users <at> lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Piotr Jachowicz