is_base_of.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // (C) Copyright Rani Sharoni 2003-2005.
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. //
  6. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  7. #ifndef BOOST_TT_IS_BASE_OF_HPP_INCLUDED
  8. #define BOOST_TT_IS_BASE_OF_HPP_INCLUDED
  9. #include <boost/type_traits/is_base_and_derived.hpp>
  10. #include <boost/type_traits/is_same.hpp>
  11. #include <boost/type_traits/is_class.hpp>
  12. namespace boost {
  13. namespace detail{
  14. template <class B, class D>
  15. struct is_base_of_imp
  16. {
  17. typedef typename remove_cv<B>::type ncvB;
  18. typedef typename remove_cv<D>::type ncvD;
  19. BOOST_STATIC_CONSTANT(bool, value = (
  20. (::boost::detail::is_base_and_derived_impl<ncvB,ncvD>::value) ||
  21. (::boost::is_same<ncvB,ncvD>::value && ::boost::is_class<ncvB>::value)));
  22. };
  23. }
  24. template <class Base, class Derived> struct is_base_of
  25. : public integral_constant<bool, (::boost::detail::is_base_of_imp<Base, Derived>::value)> {};
  26. template <class Base, class Derived> struct is_base_of<Base, Derived&> : false_type{};
  27. template <class Base, class Derived> struct is_base_of<Base&, Derived&> : false_type{};
  28. template <class Base, class Derived> struct is_base_of<Base&, Derived> : false_type{};
  29. } // namespace boost
  30. #endif // BOOST_TT_IS_BASE_AND_DERIVED_HPP_INCLUDED