is_base_of.qbk 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. [/
  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).
  6. ]
  7. [section:is_base_of is_base_of]
  8. template <class Base, class Derived>
  9. struct is_base_of : public __tof {};
  10. __inherit If Base is base class of type Derived or if both types are the same
  11. class type then inherits from __true_type,
  12. otherwise inherits from __false_type.
  13. This template will detect non-public base classes, and ambiguous base classes.
  14. It also detects indirect base classes - which is to say __is_base_of<B, D> inherits
  15. from __true_type if B is located anywhere in the inheritance tree of D.
  16. Note that `is_base_of<X,X>` will inherit from __true_type if X is a class type.
  17. This is a change in behaviour
  18. from Boost-1.39.0 in order to track the emerging C++0x standard.
  19. Types `Base` and `Derived` must not be incomplete types.
  20. __std_ref 10.
  21. __header ` #include <boost/type_traits/is_base_of.hpp>` or ` #include <boost/type_traits.hpp>`
  22. [all_compilers]
  23. __examples
  24. [:Given: ` class Base{}; class Derived : public Base{};` ]
  25. [:`is_base_of<Base, Derived>` inherits from `__true_type`.]
  26. [:`is_base_of<Base, Derived>::type` is the type `__true_type`.]
  27. [:`is_base_of<Base, Derived>::value` is an integral constant
  28. expression that evaluates to /true/.]
  29. [:`is_base_of<Base, Base>::value` is an integral constant
  30. expression that evaluates to /true/: a class is regarded as it's own base.]
  31. [:`is_base_of<T, T>::value_type` is the type `bool`.]
  32. [endsect]