Boost logo

Boost :

Subject: Re: [boost] Boost.Conversion - pre review request
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-07-09 11:00:59


Hartmut Kaiser wrote:
>
>> > On Jul 9, 2011, at 2:52 AM, Jeroen Habraken wrote:
>> >> On 9 July 2011 04:10, Gordon Woodhull <gordon_at_[hidden]>
>> wrote:
>> >>> (Jeroen, if you're reading this, can you convert to/from e.g.
>> >>> hexadecimal with Coerce?)
>> >>
>> >> It isn't possible at the moment but it is to be re-added during the
>> >> Google Summer of Code. The syntax will probably look something like
>> >> coerce::as<int>("0x17", tag::hex());
>> >
>> > Aha, that's why I asked. Not currently compatible with
>> Boost.Conversion:
>> > just as there's no way to supply iostream manipulators for
>> > Convert-style formatting, there's no way to supply tags for Coerce-
>> style.
>> >
>> > Vicente, do you have any thoughts on whether extra parameters could be
>> > added generically?
>>
>> I don't think that these kind of specific conversions could be added to
>> simple type-to-type conversions. As I signaled during the Boost.Convert
>> review I will use instead an auxiliary string stream and output and input
>> the types we want to convert using as many manipulators as the user
>> wants.
>>
>> I have added an example here
>> http://svn.boost.org/svn/boost/sandbox/conversion/libs/conversion_ext/exam
>> ple/formatted.cpp
>> that shows how I will apply these kind of conversions. As you can see
>> this
>> example doesn't make use of the Boost.Conversion generic functions when
>> manipulators are needed. Instead it uses either a template io stream
>> (extractor_stream) that is able to extract the type given as parameter
>> when the extract manipulator is used or a io stream ( via_stream) that is
>> able to extract any type given as parameter of the manipulator
>> extract_to.
>
> This might be off topic and purely esthetical (i.e. personal taste), but I
> find the mix of operator>>() and operator<<() in the same expression to be
> more than confusing. That's (for me) clearly not a viable solution.
>
>

I agree with you that the mix of i/o operators could be confusing. Maybe it
could be less confusing if we write them as follows

      std::string si2 =
      ii =>> std::uppercase =>> std::hex =>> via_stream()
>> extract_to(*std::string*)();

If I'm not wrong =>> is left to right associative, so the preceding is
equivalent to

      (ii =>> (std::uppercase =>> (std::hex =>> via_stream())))
>> extract_to(*std::string*)();

Note that I'm not proposing to include this on Boost.Conversion.

Best,
Vicente

--
View this message in context: http://boost.2283326.n4.nabble.com/Boost-Conversion-pre-review-request-tp3650286p3656269.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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