Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-10-09 08:32:34


Yitzhak Sapir <yitzhaks_at_[hidden]> writes:

> On Tue, 8 Oct 2002, Aleksey Gurtovoy wrote:
>
> > > Also why does list_c allow specifying a type but defaults all
> > > parameters to long?
> > > Couldn't list_c<class T, T c1, T c2, etc.> have been used? (Like in
> > > integral_c?)
> >
> > Nope, because due to its variadic interface 'list_c<T,...>' needs to reserve
> > some single value for denoting unused arguments, and taking that value out
> > of range of possible values of type 'T' is not really a feasible option
> > (consider, for instance, T == bool).
>
> This seems to work on VC:
>
> template <class T> struct LargerThan
> {
> typedef long type;
> enum { illegal_value = 0xBADBAD };
> };
>
> template <> struct LargerThan<bool>
> {
> typedef char type;
> enum { illegal_value = -1 };
> };

I don't think substituting char for bool is really appropriate in a
metaprogramming context, do you? This is, after all, "programming with
types".

-- 
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com

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