|
Boost : |
Subject: Re: [boost] [review] string convert
From: Jeremy Maitin-Shepard (jeremy_at_[hidden])
Date: 2011-05-05 15:14:35
On 05/05/2011 10:32 AM, Stewart, Robert wrote:
> Jeff Flinn wrote:
>> Stewart, Robert wrote:
>>> Vicente BOTET wrote:
>>>> De : "Vladimir Batov"
>>>>> "Stewart, Robert" wrote
>>
>>>>> Maybe to avoid the temptation of pairing up we could
>>>>> simplify (at least from the user perspectives) down to:
>>>>>
>>>>> 1. T convert_cast(S)
>>>>> 2. T convert_cast(S, T, throw_t =nothrow)
>>>> I don't see why (2) the user could want to throw when is
>>>>> giving a fallback. So the throw_t =nothrow is not needed.
>>>
>>> That's the non-DefaultConstructible, no-sentinel use case:
>>>
>>> struct example
>>> {
>>> example(int);
>>> };
>>>
>>> If one wants an exception to indicate conversion failure,
>>> an initial value is needed and the desire for an exception
>>> must be noted:
>>>
>>> example const e(convert_cast<example>("1", 3, throw_));
>>
>> Sorry if I'm just being dense, but if the above throws, the
>> default value is never used, so why supply it?
>
> Think about how convert_cast() might be implemented:
>
[snip]
Is conflating the fallback value with the initial value used by a
stringstream-based implementation really a good idea?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk