Boost logo

Boost Users :

From: Martin Apel (martin.apel_at_[hidden])
Date: 2007-08-21 06:14:26


Hughes, James wrote:
> Hello all,
>
> I want some template code to assert if the passed in template type is
> NOT derived from a particular base class.
>
> I've looked through the Template Metaprogamming book, but haven't seen
> anything that can do this, but I seem to remember something along those
> lines.
>
> Can anyone help?
>
> James
>
>
Hi James,

the easiest way is something like the following:

#include <boost/type_traits.hpp>
#include <boost/static_assert.hpp>

BOOST_STATIC_ASSERT (boost::is_base_of<Base, Derived>::value);

Hope this helps,

Martin


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