Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-10-27 23:20:23


Gabriel Dos Reis wrote:
> The way I'm intending to implement compiler support for type traits in
> GCC is to have "built-in" operators like __builtin_xxx() (xxx ranging
> over is_pod, has_trivial_copy_ctor, has_trivial_dtor, ...) to take a
> type-id and return boolean constant expression.
>
> Therefore,
>
> | template< typename T > struct is_pod
> | {
> | BOOST_STATIC_CONSTANT(bool, value =
>
> will be written
>
> BOOST_STATIC_CONSTANT(bool, value = __builtin_is_pod(T))
>

Interesting! But wouldn't it be easier just to drop

    template<typename X> __yes_type __builtin_is_pod();

into the global scope when X is defined/instantiated for the first time (if
it's a template class)?

After all, there isn't much of a difference between

          BOOST_STATIC_CONSTANT(bool, value = __builtin_is_pod(T))

and
          BOOST_STATIC_CONSTANT(bool, value = sizeof(__builtin_is_pod<T>())
> 1)

Just wondering if these built-in operators worth the complications of
introducing them :).

>
> [ FWIW, I implemented the static-assert support in GCC at Santa Cruz,
> just after reporting (Robert, Judy and me) on the proposal.
> It isn't yet in FSF official source ]

Cool! I hope other vendors will follow the trend with equal eagerness :).

Aleksey


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