|
Boost : |
Subject: Re: [boost] Review Request: Introduction of boost::string namespace, and string-conversion functions
From: Anders Dalvander (boost_at_[hidden])
Date: 2009-02-14 04:37:37
On Fri, Feb 13, 2009 at 07:15 +1000, Vladimir Batov
<batov_at_[hidden]> wrote:
>> 2. The name of the namespace.
>>
>> People largely seem content with "boost::string".
I think that is a pretty bold statement as your proposal for
boost::string was initially posted merely 26 hours earlier.
Perhaps this library should be bundled with the Boost String Algorithms
Library, and reside in the boost::algorithm namespace.
>> 3. Naming of the conversion functions.
>>
>> The "to/from/is" set seems to sit well with the majority of people.
I really like the compactness of to/from/is, but something about it
feels strange. It feels a bit backward as boost::string::to converts
from a string, and boost::string::from converts to a string.
Perhaps parse and to_string (or construct).
namespace bsa = boost::algorithm; // or boost::string, or
boost::convert, or boost::text, or boost.
int i_from_s = bsa::parse<int>(s);
std::string s_from_i = bsa::to_string<std::string>(i);
>> 8. Throw/No-Throw Behavior.
>>
>> You might have noticed that the interface above *never* throws
anything on
failure.
>> >> template<class T, class String>
>> >> boost::string::value<T>
>> >> boost::string::to(String const&, T const& =T()) throw();
>> >> template<class T>
>> >> boost::string::value<std::string>
>> >> boost::string::from(T const&) throw();
I don't think it is a good idea to have the nothrow exception
specification on either boost::string::from nor boost::string::to as the
underlying mechanism (iostreams I would believe) or copy-construction of
T or construction of String could throw exceptions. Nothrow simply
cannot be guaranteed.
Regards,
Anders Dalvander
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk