Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-06-13 21:16:37


David Abrahams wrote:
> I think it's nice, but would prefer to call the template
> "initialized".

Me too (in fact, that's exactly how something like this is called in our
code :).

> Also, I note that it /only/ works with built-in
> integer types. What about pointers and floating types? I think
> these deserve an "initialized" type as well.

Yes, it should be something like this:

template< typename T
        , typename non_type_parameter<T>::type Default
            = typename non_type_parameter<T>::type()
>
struct initialized : boost::mpl::select_type<
          boost::is_pointer<T>::value
        , initialized_ptr<T>
        , initialized_arithmetic<T>
>::type
    {
    // ...
    };

where 'non_type_parameter<double>::type' (or 'float') gives you something
like 'long', so at least you can have an integer-based initialization:

initialized<double> d; // ok
initialized<double, 15> d1; // ok
// initialized<double, 15.5> d1; // error

Also, overloading of unary operator& to make it return an address of
internal object might make sense too.

Aleksey


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