|
Boost : |
Subject: Re: [boost] Formal Review Request: Boost.String.Convert
From: David Abrahams (dave_at_[hidden])
Date: 2009-02-18 12:15:59
on Wed Feb 18 2009, "Vladimir Batov" <batov-AT-people.net.au> wrote:
>> convert::to_string<wstring>,
>> convert::to_integral<int, rounding::down>,
>> convert::transcode_string<wstring, native_mbcs>, ...
>
> How about
>
> convert::to<wstring>
> convert::to<int, rounding::down>
> convert::to<wstring, native_mbcs>
>
> I am serious. I actually like it. I understand you do not like my to/from but you are
> almost there. By eliminating the repetition (as for _string<wstring) we get a laconic
> and expressive (IMHO of course) interface. No need for various to_string, to_integral,
> transcode_string, etc. We get rid of the string namespace as well (it should be a plus
> isn't it?). So, it'd be
>
> int i = boost::convert::to<int>(str); // explicit 'int' type
> int i = boost::convert::to(str, -1); // deduced 'int'
> string s = boost::convert::to<string>(-1); // explicit std::string type
> string s = boost::convert::to(-1, "failed to convert"); // deduced std::string
> wstring s = boost::convert::to<wstring>(-1); // explicit std::wstring type
> wstring s = boost::convert::to(-1, L"failed to convert"); // deduced std::wstring
This looks pretty nice to me at first glance.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk