Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: Boost.Convert
From: Vladimir Batov (batov_at_[hidden])
Date: 2009-02-25 04:35:04


>> From: "Andrew Troschinetz" <ast_at_[hidden]>
>> But you see how easily things can get mixed up. I'd be happier picking
>> one interface, either convert or convert_to or convert_from to keep
>> things clear. Though that might make others unhappy, I don't know.
>
> I understand. I am of an opinion that we should not be deciding for people
> what they are to use... especially for such a diverse group as Boosters.
> We'll provide them with convert, convert_to, convert_from which I hope
> will cover all the preferences.

I thought some more about you mentioning "one interface... to keep things
clear" and I think I agree with you. I'll be only leaving "convert_to or
convert_from".

>> ... when I see >> and std::hex on one line, my mind immediately goes to
>> streams because std::hex is a stream manipulator.

We currently have

convert_to<int>(str) >> boost::nothrow >> std::hex;

I've been thinking of other operators and I am not sure anyone stands out as
a better candidate. Like

    convert_to<int>(str) & boost::nothrow;

might be good but then

    convert_to<int>(str) & boost::nothrow & std::hex;

does not look that hot. So, I personally feel better with op>> as it indeed
exposes the underlying IOStreams and tells the user I am the one you've
known for many years. Do you have anything particular in mind?

There is an alternative to accommodate throwing like

    convert_to<int, boost::nothrow>(str) >> std::hex;

but it feels too long, isn't it?

Best,
V.


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