Boost logo

Boost :

Subject: Re: [boost] Review Request: Introduction of boost::string namespace and string-conversion functions
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-02-12 11:23:03


David Abrahams wrote:
> on Wed Feb 11 2009, Andrey Semashev <andrey.semashev-AT-gmail.com> wrote:
>
>> Vladimir.Batov_at_[hidden] wrote:
>>> int i;
>>> std::string s;
>>>
>>> 1) int i_from_s = boost::string::to<int>(s); // throws
>> bs::to_string?
>
> The above is converting a string to an int, so to_string would be
> inappropriate. I.e. string::to and to_string are grammatically different.
>
>>> 2) std::string s_from_i = boost::string::from<int>(i);
>> bs::from_string?
>
> Ditto.

Oh, I certainly meant in reverse.

>> Everything looks fine with me, except that I would suggest using a more explicit
>> syntax for the default value specification. Like this:
>>
>> boost::string::to<int>(s).with_default(-1);
>
> boost::string::to<int>(s, _default=-1)
>
> ?
>
> see Boost.Parameter

Yes, that's a good alternative.


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