Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58216 - in branches/release: boost/type_traits libs/type_traits libs/type_traits/test
From: john_at_[hidden]
Date: 2009-12-07 08:06:54


Author: johnmaddock
Date: 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
New Revision: 58216
URL: http://svn.boost.org/trac/boost/changeset/58216

Log:
Merge type_traits bug fixes from Trunk.
Properties modified:
   branches/release/boost/type_traits/ (props changed)
   branches/release/libs/type_traits/ (props changed)
Text files modified:
   branches/release/boost/type_traits/has_new_operator.hpp | 47 ++++++++++++++++++++++++++++++---------
   branches/release/boost/type_traits/intrinsics.hpp | 2
   branches/release/boost/type_traits/is_signed.hpp | 10 +++++++
   branches/release/boost/type_traits/is_unsigned.hpp | 11 +++++++-
   branches/release/libs/type_traits/test/aligned_storage_empy_test.cpp | 21 ++++++++++-------
   branches/release/libs/type_traits/test/has_operator_new_test.cpp | 11 +++++++++
   branches/release/libs/type_traits/test/is_abstract_test.cpp | 4 +++
   branches/release/libs/type_traits/test/test.hpp | 4 +++
   8 files changed, 86 insertions(+), 24 deletions(-)

Modified: branches/release/boost/type_traits/has_new_operator.hpp
==============================================================================
--- branches/release/boost/type_traits/has_new_operator.hpp (original)
+++ branches/release/boost/type_traits/has_new_operator.hpp 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
@@ -26,7 +26,7 @@
     template <typename T>
     struct has_new_operator_impl {
         template<class U>
- static type_traits::yes_type check_sig(
+ static type_traits::yes_type check_sig1(
             U*,
             test<
             void *(*)(std::size_t),
@@ -34,7 +34,10 @@
>* = NULL
         );
         template<class U>
- static type_traits::yes_type check_sig(
+ static type_traits::no_type check_sig1(...);
+
+ template<class U>
+ static type_traits::yes_type check_sig2(
             U*,
             test<
             void *(*)(std::size_t, const std::nothrow_t&),
@@ -42,7 +45,10 @@
>* = NULL
         );
         template<class U>
- static type_traits::yes_type check_sig(
+ static type_traits::no_type check_sig2(...);
+
+ template<class U>
+ static type_traits::yes_type check_sig3(
             U*,
             test<
             void *(*)(std::size_t, void*),
@@ -50,10 +56,11 @@
>* = NULL
         );
         template<class U>
- static type_traits::no_type check_sig(...);
+ static type_traits::no_type check_sig3(...);
+
 
         template<class U>
- static type_traits::yes_type check_sig2(
+ static type_traits::yes_type check_sig4(
             U*,
             test<
             void *(*)(std::size_t),
@@ -61,7 +68,10 @@
>* = NULL
         );
         template<class U>
- static type_traits::yes_type check_sig2(
+ static type_traits::no_type check_sig4(...);
+
+ template<class U>
+ static type_traits::yes_type check_sig5(
             U*,
             test<
             void *(*)(std::size_t, const std::nothrow_t&),
@@ -69,7 +79,10 @@
>* = NULL
         );
         template<class U>
- static type_traits::yes_type check_sig2(
+ static type_traits::no_type check_sig5(...);
+
+ template<class U>
+ static type_traits::yes_type check_sig6(
             U*,
             test<
             void *(*)(std::size_t, void*),
@@ -77,21 +90,29 @@
>* = NULL
         );
         template<class U>
- static type_traits::no_type check_sig2(...);
+ static type_traits::no_type check_sig6(...);
 
         // GCC2 won't even parse this template if we embed the computation
         // of s1 in the computation of value.
         #ifdef __GNUC__
- BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(has_new_operator_impl<T>::template check_sig<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(has_new_operator_impl<T>::template check_sig1<T>(0)));
             BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(has_new_operator_impl<T>::template check_sig2<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(has_new_operator_impl<T>::template check_sig3<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(has_new_operator_impl<T>::template check_sig4<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(has_new_operator_impl<T>::template check_sig5<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(has_new_operator_impl<T>::template check_sig6<T>(0)));
         #else
             #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
                 #pragma warning(push)
                 #pragma warning(disable:6334)
             #endif
 
- BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig1<T>(0)));
             BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(check_sig2<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(check_sig3<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(check_sig4<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(check_sig5<T>(0)));
+ BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(check_sig6<T>(0)));
 
             #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
                 #pragma warning(pop)
@@ -100,7 +121,11 @@
         BOOST_STATIC_CONSTANT(bool, value =
            (::boost::type_traits::ice_or<
             (s1 == sizeof(type_traits::yes_type)),
- (s2 == sizeof(type_traits::yes_type))
+ (s2 == sizeof(type_traits::yes_type)),
+ (s3 == sizeof(type_traits::yes_type)),
+ (s4 == sizeof(type_traits::yes_type)),
+ (s5 == sizeof(type_traits::yes_type)),
+ (s6 == sizeof(type_traits::yes_type))
>::value)
         );
     };

Modified: branches/release/boost/type_traits/intrinsics.hpp
==============================================================================
--- branches/release/boost/type_traits/intrinsics.hpp (original)
+++ branches/release/boost/type_traits/intrinsics.hpp 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
@@ -149,7 +149,7 @@
 # define BOOST_IS_CLASS(T) __is_class(T)
 # define BOOST_IS_ENUM(T) __is_enum(T)
 # define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
-# if !defined(unix) || defined(__LP64__)
+# if (!defined(unix) && !defined(__unix__)) || defined(__LP64__)
       // GCC sometimes lies about alignment requirements
       // of type double on 32-bit unix platforms, use the
       // old implementation instead in that case:

Modified: branches/release/boost/type_traits/is_signed.hpp
==============================================================================
--- branches/release/boost/type_traits/is_signed.hpp (original)
+++ branches/release/boost/type_traits/is_signed.hpp 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
@@ -27,10 +27,18 @@
 #if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238)
 
 template <class T>
+struct is_signed_values
+{
+ typedef typename remove_cv<T>::type no_cv_t;
+ BOOST_STATIC_CONSTANT(no_cv_t, minus_one = (static_cast<no_cv_t>(-1)));
+ BOOST_STATIC_CONSTANT(no_cv_t, zero = (static_cast<no_cv_t>(0)));
+};
+
+template <class T>
 struct is_signed_helper
 {
    typedef typename remove_cv<T>::type no_cv_t;
- BOOST_STATIC_CONSTANT(bool, value = (!(static_cast<no_cv_t>(-1) > 0)));
+ BOOST_STATIC_CONSTANT(bool, value = (!(::boost::detail::is_signed_values<T>::minus_one > boost::detail::is_signed_values<T>::zero)));
 };
 
 template <bool integral_type>

Modified: branches/release/boost/type_traits/is_unsigned.hpp
==============================================================================
--- branches/release/boost/type_traits/is_unsigned.hpp (original)
+++ branches/release/boost/type_traits/is_unsigned.hpp 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
@@ -27,10 +27,17 @@
 #if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238)
 
 template <class T>
-struct is_ununsigned_helper
+struct is_unsigned_values
 {
    typedef typename remove_cv<T>::type no_cv_t;
- BOOST_STATIC_CONSTANT(bool, value = (static_cast<no_cv_t>(-1) > 0));
+ BOOST_STATIC_CONSTANT(no_cv_t, minus_one = (static_cast<no_cv_t>(-1)));
+ BOOST_STATIC_CONSTANT(no_cv_t, zero = (static_cast<no_cv_t>(0)));
+};
+
+template <class T>
+struct is_ununsigned_helper
+{
+ BOOST_STATIC_CONSTANT(bool, value = (::boost::detail::is_unsigned_values<T>::minus_one > ::boost::detail::is_unsigned_values<T>::zero));
 };
 
 template <bool integral_type>

Modified: branches/release/libs/type_traits/test/aligned_storage_empy_test.cpp
==============================================================================
--- branches/release/libs/type_traits/test/aligned_storage_empy_test.cpp (original)
+++ branches/release/libs/type_traits/test/aligned_storage_empy_test.cpp 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
@@ -22,7 +22,7 @@
     struct alignment_implementation1
     {
         boost::detail::aligned_storage::aligned_storage_imp<N,Alignment> type;
- const void* address() const { return this; }
+ const void* address() const { return type.address(); }
     };
     
     template< unsigned N, unsigned Alignment >
@@ -39,24 +39,24 @@
     };
     
     template< unsigned N, class T >
- const void* get_address1()
+ std::ptrdiff_t get_address1()
     {
- alignment_implementation1<N*sizeof(T), tt::alignment_of<T>::value> imp1;
- return imp1.address();
+ static alignment_implementation1<N*sizeof(T), tt::alignment_of<T>::value> imp1;
+ return static_cast<const char*>(imp1.address()) - reinterpret_cast<const char*>(&imp1);
     }
 
     template< unsigned N, class T >
- const void* get_address2()
+ std::ptrdiff_t get_address2()
     {
- alignment_implementation2<N*sizeof(T), tt::alignment_of<T>::value> imp2;
- return imp2.address();
+ static alignment_implementation2<N*sizeof(T), tt::alignment_of<T>::value> imp2;
+ return static_cast<const char*>(imp2.address()) - reinterpret_cast<const char*>(&imp2);
     }
 
     template< class T >
     void check()
     {
- const void* addr1 = get_address1<0,T>();
- const void* addr2 = get_address2<0,T>();
+ std::ptrdiff_t addr1 = get_address1<0,T>();
+ std::ptrdiff_t addr2 = get_address2<0,T>();
         //
         // @remark: only the empty case differs
         //
@@ -101,6 +101,9 @@
 #ifdef BOOST_HAS_MS_INT64
 check<__int64>();
 #endif
+#ifdef BOOST_HAS_LONG_LONG
+check<long long>();
+#endif
 
 check<int(*)(int)>();
 check<int*>();

Modified: branches/release/libs/type_traits/test/has_operator_new_test.cpp
==============================================================================
--- branches/release/libs/type_traits/test/has_operator_new_test.cpp (original)
+++ branches/release/libs/type_traits/test/has_operator_new_test.cpp 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
@@ -33,6 +33,16 @@
    void* operator new[] (std::size_t size, void* ptr);
 };
 
+struct class_with_all_ops
+{
+ void * operator new(std::size_t);
+ void* operator new(std::size_t size, const std::nothrow_t&);
+ void* operator new[](std::size_t size);
+ void* operator new[](std::size_t size, const std::nothrow_t&);
+ void* operator new (std::size_t size, void* ptr);
+ void* operator new[] (std::size_t size, void* ptr);
+};
+
 TT_TEST_BEGIN(has_new_operator)
 
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_new_operator<class_with_new_op>::value, true);
@@ -42,6 +52,7 @@
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_new_operator<class_with_new_op4>::value, true);
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_new_operator<class_with_new_op5>::value, true);
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_new_operator<class_with_new_op6>::value, true);
+BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_new_operator<class_with_all_ops>::value, true);
 
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_new_operator<bool>::value, false);
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_new_operator<bool const>::value, false);

Modified: branches/release/libs/type_traits/test/is_abstract_test.cpp
==============================================================================
--- branches/release/libs/type_traits/test/is_abstract_test.cpp (original)
+++ branches/release/libs/type_traits/test/is_abstract_test.cpp 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
@@ -13,6 +13,10 @@
 # include <boost/type_traits/is_abstract.hpp>
 #endif
 
+#ifdef BOOST_MSVC
+#pragma warning(disable: 4505)
+#endif
+
 
 struct TestA {};
 struct TestB { virtual void foo(void) = 0; };

Modified: branches/release/libs/type_traits/test/test.hpp
==============================================================================
--- branches/release/libs/type_traits/test/test.hpp (original)
+++ branches/release/libs/type_traits/test/test.hpp 2009-12-07 08:06:52 EST (Mon, 07 Dec 2009)
@@ -407,6 +407,10 @@
 {
    T t;
    int j;
+protected:
+ wrap();
+ wrap(const wrap&);
+ wrap& operator=(const wrap&);
 };
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk