Boost logo

Boost :

From: Hamish Mackenzie (boost_at_[hidden])
Date: 2001-11-29 21:26:24


On Fri, 2001-11-30 at 01:58, David Abrahams wrote:
>
> ----- Original Message -----
> From: "Hamish Mackenzie" <boost_at_[hidden]>
>
> > How about
> >
> > template< typename Type, Type Value >
> > struct constant
> > {
> > typedef Type type;
> > static type const value = Value;
> > operator const type &() const { return value; }
> as soon as you do this--------------^^^^^^^^^^^^

Oh yes, it should realy be
operator type () const { return value; }
shouldn't it.

> > };
>
> You need to do this:
>
> template <typename Type, Type Value>
> Type const constant<Type,Value>::value;
>
>
> Some compilers think you need to do it anyway, if you use static const
> instead of enum :(

I think some compilers might even need "= Value" to be moved out.

template< typename Type, Value >
Type const constant< Type, Value >::value = Value;

but I try not to use those compilers :-)

Hamish


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