Boost logo

Boost :

Subject: Re: [boost] Boost.Convert+Boost.Parameter
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-03-04 03:11:27

----- Original Message -----
From: "Emil Dotchevski" <emildotchevski_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, March 04, 2009 12:17 AM
Subject: Re: [boost] Boost.Convert+Boost.Parameter

> By the way, returning std::string doesn't guard against such errors:

> std::string to_string( foo const & );
> foo bar();
> char const * s=to_string(bar()).c_str(); //oops.

Here the problem is not that to_string returns a string but using c_str().
The same problem occurs when you use c_str on a local string. When the string goes out of scope the data pointeed by the recovred c_str is bad.

char* ext;

    std::string str("local");
} // Here ext points to a free memory area
// if used the code coudl not work.

Boost list run by bdawes at, gregod at, cpdaniel at, john at