Boost logo

Boost :

Subject: Re: [boost] [review] string convert
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-05-04 12:23:17


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.

Right, sorry, I am reading this somewhat out-of-order.

But: all of the built-in numeric types are default-constructable, and I
would guess that any definition of "numeric type concept" would include
a default ctor that sets it to zero. So, I believe this is not useful.

Presumably someone will now argue that this is a "general purpose
conversion framework" that should work with lots of different types
including some that are not default-constructable. I would reply that
that is an unnecessary over-complication of the problem. We have
perhaps four cases:

- Numbers.
- Enumerations.
- Booleans, which can be considered much like one or other of the above.
- Compound types.

I would consider each of those independently. By all means try to be
consistent between them, but don't try to unnecessarily coerce them all
into a single feature.

Regards, Phil.


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