Boost logo

Boost :

Subject: Re: [boost] Boost.Convert+Boost.Parameter
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-03-03 16:56:56


On Tue, Mar 3, 2009 at 1:26 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
> Emil Dotchevski wrote:
>> 2) convert<std::string> necessarily returns std::string (I think it's
>> important user-defined conversions to have the freedom to return char
>> const *. Many interfaces that take strings are commonly overloaded for
>> std::string and char const * for efficiency reasons.)
>
> How common is this going to be in reality?  Won't returning
> const char* usually introduce problems with memory management?

I think that whether this is common or not is not important, my point
is that it is a valuable optimization technique.

If conversion of objects of type foo to string is for some reason
critical for performance, you can have foo contain a std::string and
make its to-string overload return a char const *, through
std::string::c_str(). Even if I wanted to-string to return std::string
const &, convert<std::string> won't work.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk