|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2002-10-23 11:27:58
Yitzhak Sapir <yitzhaks_at_[hidden]> writes:
> On Wed, 23 Oct 2002, Peter Dimov wrote:
>
> > From: "Aleksey Gurtovoy" <agurtovoy_at_[hidden]>
> > > Peter Dimov wrote:
> > > > is_incomplete can never work. It violates ODR. ;-)
> > >
> > > You are right, of course. It should be something like this instead:
> >
> > [...]
> >
> > > 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. ;-)
>
> It could be used as BOOST_STATIC_ASSERT_COMPLETE(T).
That's spelled
typedef int not_a_complete_type[sizeof(T)];
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Building C/C++ Extensions for Python: Dec 9-11, Austin, TX http://www.enthought.com/training/building_extensions.html
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk