
On Tue, Mar 3, 2009 at 1:26 PM, Steven Watanabe <watanabesj@gmail.com> 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