
Piotr Jachowicz wrote:
Hello,
Igor R
writes: 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".
Piotr - I don't think this is "unexpected behavior" to most. You have *not* bound abc. You have bound a pointer. What that pointer points to may change and when you use the pointer it may very well point to something different than at the time of the bind. This isn't "unexpected". Your bind is to a pointer. You need to either ensure that the value pointed at doesn't change or you can pass an object containing the data itself. michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com