Boost logo

Boost :

From: Peder Holt (peder.holt_at_[hidden])
Date: 2005-06-29 03:34:43


On 6/28/05, Arkadiy Vertleyb <vertleyb_at_[hidden]> wrote:
> "Alexander Nasonov" <alnsn-boost_at_[hidden]> wrote
>
> > The following sentence in typeof.htm:
> >
> > Other integral types, such as enums, need to be described explicitly
> with the
> > BOOST_TYPEOF_INTEGRAL macro, like (BOOST_TYPEOF_INTEGRAL(MyEnum))
> >
> > contrudicts with footnote in 3.9.1/7:
> > 43) Therefore, enumerations (7.2) are not integral: however, enumerations
> can be
> > promoted to int, unsigned int, long or unsigned long, as specified in 4.5
> >
> > It should be easy to fix documentation. Not sure what to do with
> > BOOST_TYPEOF_INTEGRAL, though.
>
> BOOST_TYPEOF_INTEGRAL is used to denote template parameters which can be
> converted to compile-time integers, but, for some reason can't be recognized
> by the means of PP. Examples include integral types that are represented
> with more than two tokens (unsigned long int), enums, and dependent template
> parameters (template<class T, T n> class ...) It can also be used with any
> regular integral template parameters to avoid the "clever" PP code that is
> used to recognize it (which may be useful for porting). IOW, this maybe
> thouhgt of as if "unsigned int" is internally converted to
> BOOST_TYPEOF_INTEGRAL(unsigned int).
>
> I am not sure how such a beast should be called. Maybe we should introduce
> a couple of synonyms, such as:
>
> #define BOOST_TYPEOF_ENUM BOOST_TYPEOF_INTEGRAL
> #define BOOST_TYPEOF_DEPENDENT(x) BOOST_TYPEOF_INTEGRAL(P ## x)

It would also be possible to add a bit of syntactic sugar to allow:
enum color {...};
template<color> some_class {};
template<template <typename,int> class T> struct tt_class {};
template<typename A1,T A2> struct dependent_class {};
BOOST_TYPEOF_REGISTER_TEMPLATE(some_class, (enum(color)) );
BOOST_TYPEOF_REGISTER_TEMPLATE(tt_class, (template((typename)(int))) );
BOOST_TYPEOF_REGISTER_TEMPLATE(dependent_class, (typename)(dependent(0)) );

Regards,
Peder

>
> Regards,
> Arkadiy
>
>
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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