diff --git a/include/boost/type_traits/is_base_and_derived.hpp b/include/boost/type_traits/is_base_and_derived.hpp index 8367b76..59f228f 100644 --- a/include/boost/type_traits/is_base_and_derived.hpp +++ b/include/boost/type_traits/is_base_and_derived.hpp @@ -15,10 +15,10 @@ #include #include #include -#include #include #include #endif +#include // should be the last #include #include @@ -212,7 +212,7 @@ struct is_base_and_derived_impl typedef is_base_and_derived_select< ::boost::is_class::value, ::boost::is_class::value, - ::boost::is_same::value> selector; + ::boost::is_same::value> selector; typedef typename selector::template rebind binder; typedef typename binder::type bound_type; @@ -222,7 +222,10 @@ struct is_base_and_derived_impl template struct is_base_and_derived_impl { - BOOST_STATIC_CONSTANT(bool, value = BOOST_IS_BASE_OF(B,D)); + typedef typename remove_cv::type ncvB; + typedef typename remove_cv::type ncvD; + + BOOST_STATIC_CONSTANT(bool, value = (BOOST_IS_BASE_OF(B,D) && ! ::boost::is_same::value)); }; #endif } // namespace detail diff --git a/include/boost/type_traits/is_base_of.hpp b/include/boost/type_traits/is_base_of.hpp old mode 100755 new mode 100644 index bf46da3..0cc7a32 --- a/include/boost/type_traits/is_base_of.hpp +++ b/include/boost/type_traits/is_base_of.hpp @@ -11,21 +11,32 @@ #include #include +#include #include +#include // should be the last #include #include namespace boost { + namespace detail{ + template + struct is_base_of_imp + { + typedef typename remove_cv::type ncvB; + typedef typename remove_cv::type ncvD; + BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_or< + (::boost::detail::is_base_and_derived_impl::value), + (::boost::type_traits::ice_and< ::boost::is_same::value, ::boost::is_class::value>::value)>::value)); + }; + } + BOOST_TT_AUX_BOOL_TRAIT_DEF2( is_base_of , Base , Derived - , (::boost::type_traits::ice_or< - (::boost::detail::is_base_and_derived_impl::value), - (::boost::is_same::value)>::value) - ) + , (::boost::detail::is_base_of_imp::value)) #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_of,Base&,Derived,false) diff --git a/include/boost/type_traits/is_base_of_tr1.hpp b/include/boost/type_traits/is_base_of_tr1.hpp new file mode 100644 index 0000000..177e62b --- /dev/null +++ b/include/boost/type_traits/is_base_of_tr1.hpp @@ -0,0 +1,50 @@ + +// (C) Copyright Rani Sharoni 2003-2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + +#ifndef BOOST_TT_IS_BASE_OF_TR1_HPP_INCLUDED +#define BOOST_TT_IS_BASE_OF_TR1_HPP_INCLUDED + +#include +#include +#include +#include + +// should be the last #include +#include + +namespace boost { namespace tr1{ + + namespace detail{ + template + struct is_base_of_imp + { + typedef typename remove_cv::type ncvB; + typedef typename remove_cv::type ncvD; + BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_or< + (::boost::detail::is_base_and_derived_impl::value), + (::boost::is_same::value)>::value)); + }; + } + +BOOST_TT_AUX_BOOL_TRAIT_DEF2( + is_base_of + , Base + , Derived + , (::boost::tr1::detail::is_base_of_imp::value)) + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_of,Base&,Derived,false) +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_of,Base,Derived&,false) +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_of,Base&,Derived&,false) +#endif + +} } // namespace boost + +#include + +#endif // BOOST_TT_IS_BASE_OF_TR1_HPP_INCLUDED diff --git a/test/is_base_and_derived_test.cpp b/test/is_base_and_derived_test.cpp index 34a525f..38e8fa3 100644 --- a/test/is_base_and_derived_test.cpp +++ b/test/is_base_and_derived_test.cpp @@ -41,8 +41,13 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), fal BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), false); +#if defined(TEST_STD) && (TEST_STD < 2006) +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), true); +#else BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), false); +#endif BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), true); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived::value), true); diff --git a/test/is_base_of_test.cpp b/test/is_base_of_test.cpp index f968244..86c5754 100644 --- a/test/is_base_of_test.cpp +++ b/test/is_base_of_test.cpp @@ -33,8 +33,13 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), false); +#if defined(TEST_STD) && (TEST_STD < 2006) +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), true); +#else BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), false); +#endif BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), true); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), false); BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), true); diff --git a/test/tricky_function_type_test.cpp b/test/tricky_function_type_test.cpp index c029a55..30ba24c 100644 --- a/test/tricky_function_type_test.cpp +++ b/test/tricky_function_type_test.cpp @@ -39,7 +39,11 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor::value, fals BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor::value, false); +#if defined(TEST_STD) && (TEST_STD < 2006) BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), true); // TR1 required behaviour (new to 1.34) +#else +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of::value), false); // C++0x required behaviour (new to 1.40) +#endif BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible::value), false);