$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-04-16 16:10:19
Christian Henning wrote:
> for_each( as.begin()
> , as.end()
> , bind( &print
> , bind( &std::string::c_str
> , bind( &A::name, _1 ))));
The problem here is that A::name returns a temporary std::string; the code
is similar to
char const * s = it->name().c_str();
print( s );
Since the temporary std::string is destroyed, s remains dangling. One way of
avoiding the problem is to make print() take a std::string instead of a
char*.