Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-10-24 06:00:44


Peter Dimov wrote:
> > Hmm, actually we can do even better:
> >
> > #define BOOST_IS_INCOMPLETE(T) \
> > is_incomplete< T, boost::mpl::integral_c<long,__LINE__> > \
> > /**/
> >
> > template< typename T >
> > struct something
> > : mpl::if_c<
> > BOOST_IS_INCOMPLETE(T)::value
> > , something_impl1<T>
> > , something_impl2<T>
> > >
> > {
> > };
>
> Now something<> violates ODR. ;-)

I was underslept :). Here:

    template<
          typename T
        , bool is_incomplete_ = BOOST_IS_INCOMPLETE(T)::value
>
    struct something
        : mpl::if_c<
              is_incomplete_
            , something_impl1<T>
            , something_impl2<T>
>
    {
    };

Actually, the macro is useless here (it doesn't really prevent
'is_incomplete' ODR violations within the same translation unit), and
frankly I don't see a way to solve this particular problem.

So the above is useable as far as the type you are querying keeps its
"completeness property" the same within a single translation unit. Oh, well.

Aleksey


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