Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79983 - in trunk: boost/type_traits libs/type_traits/test
From: john_at_[hidden]
Date: 2012-08-12 13:57:28


Author: johnmaddock
Date: 2012-08-12 13:57:27 EDT (Sun, 12 Aug 2012)
New Revision: 79983
URL: http://svn.boost.org/trac/boost/changeset/79983

Log:
Remove stray ; in test file.
Add some rvalue ref tests for is_convertible.
Enable use of intrinsics for Intel on Win32.
Fix rvalue ref usage in is_convertible.
Text files modified:
   trunk/boost/type_traits/intrinsics.hpp | 8 +++++++-
   trunk/boost/type_traits/is_convertible.hpp | 40 +++++++++++++++++++++++++++-------------
   trunk/libs/type_traits/test/is_convertible_test.cpp | 2 ++
   trunk/libs/type_traits/test/test.hpp | 2 +-
   trunk/libs/type_traits/test/tricky_rvalue_test.cpp | 2 ++
   5 files changed, 39 insertions(+), 15 deletions(-)

Modified: trunk/boost/type_traits/intrinsics.hpp
==============================================================================
--- trunk/boost/type_traits/intrinsics.hpp (original)
+++ trunk/boost/type_traits/intrinsics.hpp 2012-08-12 13:57:27 EDT (Sun, 12 Aug 2012)
@@ -79,7 +79,8 @@
 # define BOOST_HAS_TYPE_TRAITS_INTRINSICS
 #endif
 
-#if defined(BOOST_MSVC) && defined(BOOST_MSVC_FULL_VER) && (BOOST_MSVC_FULL_VER >=140050215)
+#if (defined(BOOST_MSVC) && defined(BOOST_MSVC_FULL_VER) && (BOOST_MSVC_FULL_VER >=140050215))\
+ || (defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1500))
 # include <boost/type_traits/is_same.hpp>
 
 # define BOOST_IS_UNION(T) __is_union(T)
@@ -221,6 +222,11 @@
 # define BOOST_ALIGNMENT_OF(T) __alignof__(T)
 # endif
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+# include <type_traits>
+# define BOOST_IS_CONVERTIBLE(T,U) (std::is_convertible<T, U>::value)
+#endif
+
 # define BOOST_HAS_TYPE_TRAITS_INTRINSICS
 #endif
 

Modified: trunk/boost/type_traits/is_convertible.hpp
==============================================================================
--- trunk/boost/type_traits/is_convertible.hpp (original)
+++ trunk/boost/type_traits/is_convertible.hpp 2012-08-12 13:57:27 EDT (Sun, 12 Aug 2012)
@@ -120,6 +120,8 @@
 struct any_conversion
 {
     template <typename T> any_conversion(const volatile T&);
+ template <typename T> any_conversion(const T&);
+ template <typename T> any_conversion(volatile T&);
     template <typename T> any_conversion(T&);
 };
 
@@ -132,8 +134,9 @@
 template <typename From, typename To>
 struct is_convertible_basic_impl
 {
- static typename add_rvalue_reference<From>::type _m_from;
- static bool const value = sizeof( boost::detail::checker<To>::_m_check(_m_from, 0) )
+ typedef typename add_rvalue_reference<From>::type rvalue_type;
+ static From _m_from;
+ static bool const value = sizeof( boost::detail::checker<To>::_m_check(static_cast<rvalue_type>(_m_from), 0) )
         == sizeof(::boost::type_traits::yes_type);
 };
 
@@ -152,6 +155,8 @@
 struct any_conversion
 {
     template <typename T> any_conversion(const volatile T&);
+ template <typename T> any_conversion(const T&);
+ template <typename T> any_conversion(volatile T&);
     // we need this constructor to catch references to functions
     // (which can not be cv-qualified):
     template <typename T> any_conversion(T&);
@@ -162,10 +167,11 @@
 {
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion ...);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To, int);
- static typename add_rvalue_reference<From>::type _m_from;
+ typedef typename add_rvalue_reference<From>::type rvalue_type;
+ static From _m_from;
 
     BOOST_STATIC_CONSTANT(bool, value =
- sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
+ sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0) ) == sizeof(::boost::type_traits::yes_type)
         );
 };
 
@@ -174,6 +180,8 @@
 struct any_conversion
 {
     template <typename T> any_conversion(const volatile T&);
+ template <typename T> any_conversion(const T&);
+ template <typename T> any_conversion(volatile T&);
     // we need this constructor to catch references to functions
     // (which can not be cv-qualified):
     template <typename T> any_conversion(T&);
@@ -186,12 +194,13 @@
     template <class T>
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion, float, T);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To, int, int);
- static typename add_rvalue_reference<From>::type _m_from;
+ typedef typename add_rvalue_reference<From>::type rvalue_type;
+ static From _m_from;
 
     // Static constants sometime cause the conversion of _m_from to To to be
     // called. This doesn't happen with an enum.
     enum { value =
- sizeof( _m_check(_m_from, 0, 0) ) == sizeof(::boost::type_traits::yes_type)
+ sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0, 0) ) == sizeof(::boost::type_traits::yes_type)
         };
 };
 
@@ -209,6 +218,9 @@
 struct any_conversion
 {
     template <typename T> any_conversion(const volatile T&);
+ template <typename T> any_conversion(const T&);
+ template <typename T> any_conversion(volatile T&);
+ template <typename T> any_conversion(T&);
 };
 
 template <typename From, typename To>
@@ -216,10 +228,11 @@
 {
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion ...);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To, int);
- static typename add_rvalue_reference<From>::type _m_from;
+ typedef typename add_rvalue_reference<From>::type rvalue_type;
+ static From _m_from;
 
     BOOST_STATIC_CONSTANT(bool, value =
- sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
+ sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0) ) == sizeof(::boost::type_traits::yes_type)
         );
 };
 
@@ -228,9 +241,10 @@
 {
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
- static typename add_rvalue_reference<From>::type _m_from;
+ typedef typename add_rvalue_reference<From>::type rvalue_type;
+ static From _m_from;
     BOOST_STATIC_CONSTANT(bool, value =
- sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
+ sizeof( _m_check(static_cast<rvalue_type>(_m_from)) ) == sizeof(::boost::type_traits::yes_type)
         );
 };
 
@@ -243,7 +257,6 @@
 {};
 
 #else
-
 //
 // This version seems to work pretty well for a wide spectrum of compilers,
 // however it does rely on undefined behaviour by passing UDT's through (...).
@@ -253,7 +266,8 @@
 {
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
- static typename add_rvalue_reference<From>::type _m_from;
+ typedef typename add_rvalue_reference<From>::type rvalue_type;
+ static From _m_from;
 #ifdef BOOST_MSVC
 #pragma warning(push)
 #pragma warning(disable:4244)
@@ -262,7 +276,7 @@
 #endif
 #endif
     BOOST_STATIC_CONSTANT(bool, value =
- sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
+ sizeof( _m_check(static_cast<rvalue_type>(_m_from)) ) == sizeof(::boost::type_traits::yes_type)
         );
 #ifdef BOOST_MSVC
 #pragma warning(pop)

Modified: trunk/libs/type_traits/test/is_convertible_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/is_convertible_test.cpp (original)
+++ trunk/libs/type_traits/test/is_convertible_test.cpp 2012-08-12 13:57:27 EDT (Sun, 12 Aug 2012)
@@ -102,6 +102,8 @@
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<const int&, int>::value), true);
 #ifndef BOOST_NO_RVALUE_REFERENCES
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<const int&&, int>::value), true);
+BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int&&, const int&>::value), true);
+BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int, int&>::value), false);
 #endif
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(&)[4], const int*>::value), true);
 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(&)(int), int(*)(int)>::value), true);

Modified: trunk/libs/type_traits/test/test.hpp
==============================================================================
--- trunk/libs/type_traits/test/test.hpp (original)
+++ trunk/libs/type_traits/test/test.hpp 2012-08-12 13:57:27 EDT (Sun, 12 Aug 2012)
@@ -260,7 +260,7 @@
 {
    nothrow_copy_UDT();
    nothrow_copy_UDT(const nothrow_copy_UDT&)throw();
- ~nothrow_copy_UDT(){};
+ ~nothrow_copy_UDT(){}
    nothrow_copy_UDT& operator=(const nothrow_copy_UDT&);
    bool operator==(const nothrow_copy_UDT&)const
    { return true; }

Modified: trunk/libs/type_traits/test/tricky_rvalue_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/tricky_rvalue_test.cpp (original)
+++ trunk/libs/type_traits/test/tricky_rvalue_test.cpp 2012-08-12 13:57:27 EDT (Sun, 12 Aug 2012)
@@ -9,6 +9,7 @@
 #ifdef TEST_STD
 # include <type_traits>
 #else
+# include <boost/type_traits/is_convertible.hpp>
 # include <boost/type_traits/is_lvalue_reference.hpp>
 # include <boost/type_traits/is_rvalue_reference.hpp>
 # include <boost/type_traits/is_reference.hpp>
@@ -20,6 +21,7 @@
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_reference<int (&&)(int)>::value, true);
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_rvalue_reference<int (&)(int)>::value, false);
 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_rvalue_reference<int (&&)(int)>::value, true);
+BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int&&, int&>::value), false);
 #endif
 
 TT_TEST_END


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