Subject: Re: [boost] Formal Review Request: Boost.String.Convert
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-02-18 13:53:10
On Wed, Feb 18, 2009 at 9:26 AM, Andrey Semashev
> Emil Dotchevski wrote:
>>>> to_string doesn't need a template parameter.
>>> Actually, it does, since I might want different string types to get.
>>> now there are string and wstring, and more are coming in C++0x.
>> I've needed to convert things specifically to std::string plenty of
>> times to justify a simple interface where to_string returns
>> std::string. I want to be able, in a header file, to just say:
>> struct foo;
>> std::string to_string( foo const & );
>> std::string to_string( foo const &, fmt );
>> and be done with it.
> That simplification as absolutely not acceptable for me, as I convert to
> wstring just about as often as to string. I think that the library should
> provide flexibility in this aspect. You can create a tiny wrapper around it,
> if you only need narrow strings.
What I had in mind is that foo could implement to_string or to_wstring
or both, and the library would supply generic overloads of
to_string/to_wstring that would kick-in as needed. So, if I give you:
std::string to_string( foo const & );
then after you include foo.hpp and presumably boost/to_string.hpp, you can say
which would bind to boost::to_wstring (since there isn't a foo
overload of to_wstring) which would do the conversion using the foo
Reverge Studios, Inc.