Boost logo

Boost Users :

From: v2cechura (v2cechura_at_[hidden])
Date: 2007-11-28 09:08:55


Either use boost::is_same as Jeff Flinn suggested. Something like this:

//-----------
template <typename CT> class C {
        BOOST_STATIC_ASSERT(( ! boost::is_same<CT,D>::value));
};

class D;
//-----------

or you can do this:

//-----------
template <typename CT> class C {
};

class D;

template <> class C<D> {
BOOST_STATIC_ASSERT(false);
}
//-----------

Vaclav

> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Jeff Flinn
> Sent: Wednesday, November 28, 2007 2:53 PM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] BOOST_STATIC_ASSERT
>
> Hicham Mouline wrote:
> > hi,
> >
> > template <typename CT> class C {
> > BOOST_STATIC_ASSERT(...);
> > };
> >
> > class D;
> >
> > I would like to forbid the instantiation of C<D>.
> >
> > How can i compare CT with D to serve as the condition of
> the boost static assert=?
>
> See
>
http://www.boost.org/doc/html/boost_typetraits/reference.html#boost_typetrai
ts.is_same
>
> You may also need to use other type_traits to remove CV and
> reference/pointer qualifiers.
>
> Jeff Flinn


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net