$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r55404 - in trunk: boost/tr1 boost/type_traits libs/tr1/test libs/type_traits/test
From: john_at_[hidden]
Date: 2009-08-04 13:15:52
Author: johnmaddock
Date: 2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
New Revision: 55404
URL: http://svn.boost.org/trac/boost/changeset/55404
Log:
Fix is_base_of and is_base_and_derived to conform to C++0x.
Also fixed consistency of handling cv-qualified types.
Added new trait in boost::tr1 to archive old tr1 behaviour.
Updated TR1 lib to match.
Added:
   trunk/boost/type_traits/is_base_of_tr1.hpp   (contents, props changed)
Text files modified: 
   trunk/boost/tr1/type_traits.hpp                           |     3 ++-                                     
   trunk/boost/type_traits/is_base_and_derived.hpp           |     9 ++++++---                               
   trunk/boost/type_traits/is_base_of.hpp                    |    19 +++++++++++++++----                     
   trunk/libs/tr1/test/Jamfile.v2                            |     4 ++--                                    
   trunk/libs/type_traits/test/is_base_and_derived_test.cpp  |     5 +++++                                   
   trunk/libs/type_traits/test/is_base_of_test.cpp           |     5 +++++                                   
   trunk/libs/type_traits/test/tricky_function_type_test.cpp |     4 ++++                                    
   7 files changed, 39 insertions(+), 10 deletions(-)
Modified: trunk/boost/tr1/type_traits.hpp
==============================================================================
--- trunk/boost/tr1/type_traits.hpp	(original)
+++ trunk/boost/tr1/type_traits.hpp	2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
@@ -19,6 +19,7 @@
 #else
 // Boost Type Traits:
 #include <boost/type_traits.hpp>
+#include <boost/type_traits/is_base_of_tr1.hpp>
 
 namespace std { namespace tr1{
 
@@ -63,7 +64,7 @@
    using ::boost::rank;
    using ::boost::extent;
    using ::boost::is_same;
-   using ::boost::is_base_of;
+   using ::boost::tr1::is_base_of;
    using ::boost::is_convertible;
    using ::boost::remove_const;
    using ::boost::remove_volatile;
Modified: trunk/boost/type_traits/is_base_and_derived.hpp
==============================================================================
--- trunk/boost/type_traits/is_base_and_derived.hpp	(original)
+++ trunk/boost/type_traits/is_base_and_derived.hpp	2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
@@ -15,10 +15,10 @@
 #include <boost/type_traits/is_same.hpp>
 #include <boost/type_traits/is_convertible.hpp>
 #include <boost/type_traits/detail/ice_and.hpp>
-#include <boost/type_traits/remove_cv.hpp>
 #include <boost/config.hpp>
 #include <boost/static_assert.hpp>
 #endif
+#include <boost/type_traits/remove_cv.hpp>
 
 // should be the last #include
 #include <boost/type_traits/detail/bool_trait_def.hpp>
@@ -212,7 +212,7 @@
     typedef is_base_and_derived_select<
        ::boost::is_class<B>::value,
        ::boost::is_class<D>::value,
-       ::boost::is_same<B,D>::value> selector;
+       ::boost::is_same<ncvB,ncvD>::value> selector;
     typedef typename selector::template rebind<ncvB,ncvD> binder;
     typedef typename binder::type bound_type;
 
@@ -222,7 +222,10 @@
 template <typename B, typename D>
 struct is_base_and_derived_impl
 {
-    BOOST_STATIC_CONSTANT(bool, value = BOOST_IS_BASE_OF(B,D));
+    typedef typename remove_cv<B>::type ncvB;
+    typedef typename remove_cv<D>::type ncvD;
+
+    BOOST_STATIC_CONSTANT(bool, value = (BOOST_IS_BASE_OF(B,D) && ! ::boost::is_same<ncvB,ncvD>::value));
 };
 #endif
 } // namespace detail
Modified: trunk/boost/type_traits/is_base_of.hpp
==============================================================================
--- trunk/boost/type_traits/is_base_of.hpp	(original)
+++ trunk/boost/type_traits/is_base_of.hpp	2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
@@ -11,21 +11,32 @@
 
 #include <boost/type_traits/is_base_and_derived.hpp>
 #include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_class.hpp>
 #include <boost/type_traits/detail/ice_or.hpp>
+#include <boost/type_traits/detail/ice_and.hpp>
 
 // should be the last #include
 #include <boost/type_traits/detail/bool_trait_def.hpp>
 
 namespace boost {
 
+   namespace detail{
+      template <class B, class D>
+      struct is_base_of_imp
+      {
+          typedef typename remove_cv<B>::type ncvB;
+          typedef typename remove_cv<D>::type ncvD;
+          BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_or<      
+            (::boost::detail::is_base_and_derived_impl<ncvB,ncvD>::value),
+            (::boost::type_traits::ice_and< ::boost::is_same<ncvB,ncvD>::value, ::boost::is_class<ncvB>::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<Base,Derived>::value),
-         (::boost::is_same<Base,Derived>::value)>::value)
-    )
+    , (::boost::detail::is_base_of_imp<Base, Derived>::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)
Added: trunk/boost/type_traits/is_base_of_tr1.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/type_traits/is_base_of_tr1.hpp	2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
@@ -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 <boost/type_traits/is_base_and_derived.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_class.hpp>
+#include <boost/type_traits/detail/ice_or.hpp>
+
+// should be the last #include
+#include <boost/type_traits/detail/bool_trait_def.hpp>
+
+namespace boost { namespace tr1{
+
+   namespace detail{
+      template <class B, class D>
+      struct is_base_of_imp
+      {
+          typedef typename remove_cv<B>::type ncvB;
+          typedef typename remove_cv<D>::type ncvD;
+          BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_or<      
+            (::boost::detail::is_base_and_derived_impl<ncvB,ncvD>::value),
+            (::boost::is_same<ncvB,ncvD>::value)>::value));
+      };
+   }
+
+BOOST_TT_AUX_BOOL_TRAIT_DEF2(
+      is_base_of
+    , Base
+    , Derived
+    , (::boost::tr1::detail::is_base_of_imp<Base, Derived>::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 <boost/type_traits/detail/bool_trait_undef.hpp>
+
+#endif // BOOST_TT_IS_BASE_OF_TR1_HPP_INCLUDED
Modified: trunk/libs/tr1/test/Jamfile.v2
==============================================================================
--- trunk/libs/tr1/test/Jamfile.v2	(original)
+++ trunk/libs/tr1/test/Jamfile.v2	2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
@@ -60,14 +60,14 @@
       :  # test-files
       :  # requirements
       <include>$(BOOST_ROOT)/libs/type_traits/test 
-      <define>TEST_STD=1 $(TR1_PROPERTIES) ] ;
+      <define>TEST_STD=2005 $(TR1_PROPERTIES) ] ;
    }
 # Commented due to conflict between test_complex in this dir
 # and in std_headers.
    for local file5 in [ glob std_headers/*.cpp ]
    {
       all_rules += [ compile $(file5) 
-      :   <define>TEST_STD=1 $(TR1_PROPERTIES) 
+      :   <define>TEST_STD=2005 $(TR1_PROPERTIES) 
       :   $(file5:B)_std_header
       ] ;
    }
Modified: trunk/libs/type_traits/test/is_base_and_derived_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/is_base_and_derived_test.cpp	(original)
+++ trunk/libs/type_traits/test/is_base_and_derived_test.cpp	2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
@@ -41,8 +41,13 @@
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<Base,const void>::value), false);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<void,Derived>::value), false);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<const void,Derived>::value), false);
+#if defined(TEST_STD) && (TEST_STD < 2006)
+BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<int, int>::value), true);
+BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<const int, int>::value), true);
+#else
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<int, int>::value), false);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<const int, int>::value), false);
+#endif
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<VB,VD>::value), true);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<VD,VB>::value), false);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<test_abc1,test_abc3>::value), true);
Modified: trunk/libs/type_traits/test/is_base_of_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/is_base_of_test.cpp	(original)
+++ trunk/libs/type_traits/test/is_base_of_test.cpp	2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
@@ -33,8 +33,13 @@
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<Base,const void>::value), false);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<void,Derived>::value), false);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<const void,Derived>::value), false);
+#if defined(TEST_STD) && (TEST_STD < 2006)
+BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<int, int>::value), true);
+BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<const int, int>::value), true);
+#else
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<int, int>::value), false);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<const int, int>::value), false);
+#endif
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<VB,VD>::value), true);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<VD,VB>::value), false);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<test_abc1,test_abc3>::value), true);
Modified: trunk/libs/type_traits/test/tricky_function_type_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/tricky_function_type_test.cpp	(original)
+++ trunk/libs/type_traits/test/tricky_function_type_test.cpp	2009-08-04 13:15:51 EDT (Tue, 04 Aug 2009)
@@ -39,7 +39,11 @@
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<foo0_t>::value, false);
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<foo0_t>::value, false);
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<foo0_t>::value, false);
+#if defined(TEST_STD) && (TEST_STD < 2006)
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<foo0_t, foo0_t>::value), true); // TR1 required behaviour (new to 1.34)
+#else
+BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<foo0_t, foo0_t>::value), false); // C++0x required behaviour (new to 1.40)
+#endif
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<foo0_t, int>::value), false);