Subject: Re: [boost] [review] string convert
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2011-05-04 12:10:39
On May 4, 2011, at 12:03 PM, Matthew Chambers wrote:
> On 5/4/2011 10:51 AM, Gordon Woodhull wrote:
>>>> int i = convert_cast<int>(s, 17, throw_even_though_i_specified_a_failback_);
>>>> optional<int> i = convert_cast<int>(s, 17, use_optional_instead_of_throwing_);
>> These are for nondefaultable types. I probably shouldn't have used int in my example; what's a well-known example of a nondefaultable type? You must supply an initial value, but you don't want to use it.
>> Pretty rare, but if you're in that case, you'll be annoyed if you don't have these. That's why they're the ones which still take ugly extra tags even after either Barend's or Matt's simplifications.
> I understand these cases and indeed illustration would be much clearer with a non-default type. Honestly I think it's a rare enough use case that it shouldn't pollute the general interface. Separate names would perhaps be more appropriate like:
> non_defaultable_type i = no_default_convert_cast<non_defaultable_type>(s, 17);
> optional<non_defaultable_type> i = try_no_default_convert_cast<non_defaultable_type>(s, 17);
> I don't really like it either. I haven't yet seen a tasteful way to support these non-defaultable types.
I don't think extra tags which hardly anyone has to use, pollute the general interface.
But unused ugly tags or unused ugly names are all the same to me...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk