Boost logo

Boost :

Subject: Re: [boost] Boost review of the Convert library is ongoing
From: alex (alexhighviz_at_[hidden])
Date: 2014-05-19 09:54:15

>-----Original Message-----
>From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Vladimir
>Sent: 17 May 2014 00:54
>To: boost_at_[hidden]
>Subject: Re: [boost] Boost review of the Convert library is ongoing
>Vladimir Batov <vb.mail.247 <at>> writes:
>> alex <alexhighviz <at>> writes:
>> RE#4: The following is not compiling because of the way it uses enable_if
>> sstream.hpp.
>> boost::cstringstream_converter cnv;
>> std::string str = boost::convert<std::string >::from("hello",
>> JUSTIFICATION: It's not compiling because applying std::stringstream to
>> a trivial type transformation is wasteful.
>> TODO: Add "char const*->std::string" transformation specialization to
>> sstream-based converter.
>Hmm, now I am not sure if I agree with my own "justification". :-) What if
>want to apply std::sstream-provided formatting facilities to convert from,
>say, a "0xFF" hex string to a decimal string? Is it one of "char
>const*->std::string" transformations that you had in mind? I've never
>thought of this and never tried... will it even work with std::sstream?

That's not what I had in mind, and in the example you give I would expect
that the user (not the library) first converts the hex string to a number
and then the number to a decimal string.

I just expected the converter to be able to convert any Input Streamable
value(including string) into a string, and a string into an Output
Streamable value (including string). That is how I understood the type

The type-requirements page also seems to suggest that you can use the
stringstream convert for (for instance) from float to int, but I assumed
that is not intentional?

Boost list run by bdawes at, gregod at, cpdaniel at, john at