2 Copyright 2007 John Maddock.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
8 [section:is_base_of is_base_of]
9 template <class Base, class Derived>
10 struct is_base_of : public __tof {};
12 __inherit If Base is base class of type Derived or if both types are the same
13 then inherits from __true_type,
14 otherwise inherits from __false_type.
16 This template will detect non-public base classes, and ambiguous base classes.
18 Note that `is_base_of<X,X>` will always inherit from __true_type. [*This is the
19 case even if `X` is not a class type]. This is a change in behaviour
20 from Boost-1.33 in order to track the Technical Report on C++ Library Extensions.
22 Types `Base` and `Derived` must not be incomplete types.
26 __header ` #include <boost/type_traits/is_base_of.hpp>` or ` #include <boost/type_traits.hpp>`
28 __compat If the compiler does not support partial-specialization of class templates,
29 then this template can not be used with function types. There are some older compilers
30 which will produce compiler errors if `Base` is a private base class of `Derived`, or if
31 `Base` is an ambiguous base of `Derived`. These compilers include Borland C++, older
32 versions of Sun Forte C++, Digital Mars C++, and older versions of EDG based compilers.
36 [:Given: ` class Base{}; class Derived : public Base{};` ]
38 [:`is_base_of<Base, Derived>` inherits from `__true_type`.]
40 [:`is_base_of<Base, Derived>::type` is the type `__true_type`.]
42 [:`is_base_of<Base, Derived>::value` is an integral constant
43 expression that evaluates to /true/.]
45 [:`is_base_of<Base, Derived>::value` is an integral constant
46 expression that evaluates to /true/.]
48 [:`is_base_of<Base, Base>::value` is an integral constant
49 expression that evaluates to /true/: a class is regarded as it's own base.]
51 [:`is_base_of<T>::value_type` is the type `bool`.]