I have the following code:
std::string HtmlToText( std::string const& html )
{
boost::scoped_array<char> text( converter.toText( html.c_str() ) );
return text.get();
}
My concern with this code was whether or not object text would be destructed after text.get() returns but before the temporary return object std::string gets constructed. This would be a problem if it would be destructed at that time.
I searched around the C++03 standard for the rules and specifics on when to destruct objects in relation to the return statement in function scope, but I had no luck finding what I wanted. Can anyone help me find it?
I don’t have the text of the C++03 draft at hand but I seem to recall that any temporary created from the call will be destructed before the actual
textobject is deleted (LIFO ordering of automatic objects in block scope) and this should guarantee that you never run into this issue.