]> git.donarmstrong.com Git - rsem.git/blobdiff - boost/type_traits/is_convertible.hpp
Updated boost to v1.55.0
[rsem.git] / boost / type_traits / is_convertible.hpp
index c05c297eaf9b8208c081aeec63e4c49ef52db9e6..3eccadc588cc7142320b022ce9c514ccb3bd62fa 100644 (file)
 #include <boost/type_traits/detail/yes_no_type.hpp>
 #include <boost/type_traits/config.hpp>
 #include <boost/type_traits/is_array.hpp>
 #include <boost/type_traits/detail/yes_no_type.hpp>
 #include <boost/type_traits/config.hpp>
 #include <boost/type_traits/is_array.hpp>
-#include <boost/type_traits/add_reference.hpp>
 #include <boost/type_traits/ice.hpp>
 #include <boost/type_traits/is_arithmetic.hpp>
 #include <boost/type_traits/is_void.hpp>
 #ifndef BOOST_NO_IS_ABSTRACT
 #include <boost/type_traits/is_abstract.hpp>
 #endif
 #include <boost/type_traits/ice.hpp>
 #include <boost/type_traits/is_arithmetic.hpp>
 #include <boost/type_traits/is_void.hpp>
 #ifndef BOOST_NO_IS_ABSTRACT
 #include <boost/type_traits/is_abstract.hpp>
 #endif
+#include <boost/type_traits/add_lvalue_reference.hpp>
+#include <boost/type_traits/add_rvalue_reference.hpp>
+#include <boost/type_traits/is_function.hpp>
 
 #if defined(__MWERKS__)
 
 #if defined(__MWERKS__)
-#include <boost/type_traits/is_function.hpp>
 #include <boost/type_traits/remove_reference.hpp>
 #endif
 
 #include <boost/type_traits/remove_reference.hpp>
 #endif
 
@@ -39,7 +40,7 @@ namespace boost {
 
 #ifndef BOOST_IS_CONVERTIBLE
 
 
 #ifndef BOOST_IS_CONVERTIBLE
 
-// is one type convertable to another?
+// is one type convertible to another?
 //
 // there are multiple versions of the is_convertible
 // template, almost every compiler seems to require its
 //
 // there are multiple versions of the is_convertible
 // template, almost every compiler seems to require its
@@ -68,7 +69,7 @@ struct does_conversion_exist
     {
         static no_type BOOST_TT_DECL _m_check(...);
         static yes_type BOOST_TT_DECL _m_check(To);
     {
         static no_type BOOST_TT_DECL _m_check(...);
         static yes_type BOOST_TT_DECL _m_check(To);
-        static From _m_from;
+        static typename add_lvalue_reference<From>::type  _m_from;
         enum { value = sizeof( _m_check(_m_from) ) == sizeof(yes_type) };
     };
 };
         enum { value = sizeof( _m_check(_m_from) ) == sizeof(yes_type) };
     };
 };
@@ -84,7 +85,7 @@ struct does_conversion_exist<void>
 
 template <typename From, typename To>
 struct is_convertible_basic_impl
 
 template <typename From, typename To>
 struct is_convertible_basic_impl
-    : does_conversion_exist<From>::template result_<To>
+    : public does_conversion_exist<From>::template result_<To>
 {
 };
 
 {
 };
 
@@ -106,7 +107,7 @@ struct is_convertible_impl
         static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(T);
     };
 
         static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(T);
     };
 
-    static From _m_from;
+    static typename add_lvalue_reference<From>::type  _m_from;
     static bool const value = sizeof( checker<To>::_m_check(_m_from) )
         == sizeof(::boost::type_traits::yes_type);
 #pragma option pop
     static bool const value = sizeof( checker<To>::_m_check(_m_from) )
         == sizeof(::boost::type_traits::yes_type);
 #pragma option pop
@@ -119,6 +120,8 @@ struct is_convertible_impl
 struct any_conversion
 {
     template <typename T> any_conversion(const volatile T&);
 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 T> any_conversion(T&);
 };
 
@@ -131,9 +134,18 @@ template <typename T> struct checker
 template <typename From, typename To>
 struct is_convertible_basic_impl
 {
 template <typename From, typename To>
 struct is_convertible_basic_impl
 {
-    static From _m_from;
-    static bool const value = sizeof( boost::detail::checker<To>::_m_check(_m_from, 0) )
+    typedef typename add_lvalue_reference<From>::type lvalue_type;
+    typedef typename add_rvalue_reference<From>::type rvalue_type;
+    static lvalue_type _m_from;
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 6)))
+    static bool const value =
+        sizeof( boost::detail::checker<To>::_m_check(static_cast<rvalue_type>(_m_from), 0) )
+        == sizeof(::boost::type_traits::yes_type);
+#else
+    static bool const value =
+        sizeof( boost::detail::checker<To>::_m_check(_m_from, 0) )
         == sizeof(::boost::type_traits::yes_type);
         == sizeof(::boost::type_traits::yes_type);
+#endif
 };
 
 #elif (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \
 };
 
 #elif (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \
@@ -151,6 +163,8 @@ struct is_convertible_basic_impl
 struct any_conversion
 {
     template <typename T> any_conversion(const volatile T&);
 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&);
     // we need this constructor to catch references to functions
     // (which can not be cv-qualified):
     template <typename T> any_conversion(T&);
@@ -161,11 +175,19 @@ struct is_convertible_basic_impl
 {
     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 ::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 From _m_from;
+    typedef typename add_lvalue_reference<From>::type lvalue_type;
+    typedef typename add_rvalue_reference<From>::type rvalue_type; 
+    static lvalue_type _m_from;
 
 
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+    BOOST_STATIC_CONSTANT(bool, value =
+        sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0) ) == sizeof(::boost::type_traits::yes_type)
+        );
+#else
     BOOST_STATIC_CONSTANT(bool, value =
         sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
         );
     BOOST_STATIC_CONSTANT(bool, value =
         sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
         );
+#endif
 };
 
 #elif defined(__DMC__)
 };
 
 #elif defined(__DMC__)
@@ -173,6 +195,8 @@ struct is_convertible_basic_impl
 struct any_conversion
 {
     template <typename T> any_conversion(const volatile T&);
 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&);
     // we need this constructor to catch references to functions
     // (which can not be cv-qualified):
     template <typename T> any_conversion(T&);
@@ -185,13 +209,21 @@ struct is_convertible_basic_impl
     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);
     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 From _m_from;
+    typedef typename add_lvalue_reference<From>::type lvalue_type;
+    typedef typename add_rvalue_reference<From>::type rvalue_type;
+    static lvalue_type _m_from;
 
     // Static constants sometime cause the conversion of _m_from to To to be
     // called. This doesn't happen with an enum.
 
     // Static constants sometime cause the conversion of _m_from to To to be
     // called. This doesn't happen with an enum.
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+    enum { value =
+        sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0, 0) ) == sizeof(::boost::type_traits::yes_type)
+        };
+#else
     enum { value =
         sizeof( _m_check(_m_from, 0, 0) ) == sizeof(::boost::type_traits::yes_type)
         };
     enum { value =
         sizeof( _m_check(_m_from, 0, 0) ) == sizeof(::boost::type_traits::yes_type)
         };
+#endif
 };
 
 #elif defined(__MWERKS__)
 };
 
 #elif defined(__MWERKS__)
@@ -208,6 +240,9 @@ struct is_convertible_basic_impl_aux;
 struct any_conversion
 {
     template <typename T> any_conversion(const volatile T&);
 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>
 };
 
 template <typename From, typename To>
@@ -215,11 +250,19 @@ struct is_convertible_basic_impl_aux<From,To,false /*FromIsFunctionRef*/>
 {
     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 ::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 From _m_from;
+    typedef typename add_lvalue_reference<From>::type lvalue_type;
+    typedef typename add_rvalue_reference<From>::type rvalue_type; 
+    static lvalue_type _m_from;
 
 
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+    BOOST_STATIC_CONSTANT(bool, value =
+        sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0) ) == sizeof(::boost::type_traits::yes_type)
+        );
+#else
     BOOST_STATIC_CONSTANT(bool, value =
         sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
         );
     BOOST_STATIC_CONSTANT(bool, value =
         sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
         );
+#endif
 };
 
 template <typename From, typename To>
 };
 
 template <typename From, typename To>
@@ -227,10 +270,18 @@ struct is_convertible_basic_impl_aux<From,To,true /*FromIsFunctionRef*/>
 {
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
 {
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
-    static From _m_from;
+    typedef typename add_lvalue_reference<From>::type lvalue_type;
+    typedef typename add_rvalue_reference<From>::type rvalue_type;
+    static lvalue_type _m_from;
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+    BOOST_STATIC_CONSTANT(bool, value =
+        sizeof( _m_check(static_cast<rvalue_type>(_m_from)) ) == sizeof(::boost::type_traits::yes_type)
+        );
+#else
     BOOST_STATIC_CONSTANT(bool, value =
         sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
         );
     BOOST_STATIC_CONSTANT(bool, value =
         sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
         );
+#endif
 };
 
 template <typename From, typename To>
 };
 
 template <typename From, typename To>
@@ -242,7 +293,6 @@ struct is_convertible_basic_impl:
 {};
 
 #else
 {};
 
 #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 (...).
 //
 // 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 (...).
@@ -252,7 +302,9 @@ struct is_convertible_basic_impl
 {
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
 {
     static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
     static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
-    static From _m_from;
+    typedef typename add_lvalue_reference<From>::type lvalue_type;
+    typedef typename add_rvalue_reference<From>::type rvalue_type; 
+    static lvalue_type _m_from;
 #ifdef BOOST_MSVC
 #pragma warning(push)
 #pragma warning(disable:4244)
 #ifdef BOOST_MSVC
 #pragma warning(push)
 #pragma warning(disable:4244)
@@ -260,9 +312,15 @@ struct is_convertible_basic_impl
 #pragma warning(disable:6334)
 #endif
 #endif
 #pragma warning(disable:6334)
 #endif
 #endif
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+    BOOST_STATIC_CONSTANT(bool, value =
+        sizeof( _m_check(static_cast<rvalue_type>(_m_from)) ) == sizeof(::boost::type_traits::yes_type)
+        );
+#else
     BOOST_STATIC_CONSTANT(bool, value =
         sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
         );
     BOOST_STATIC_CONSTANT(bool, value =
         sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
         );
+#endif
 #ifdef BOOST_MSVC
 #pragma warning(pop)
 #endif
 #ifdef BOOST_MSVC
 #pragma warning(pop)
 #endif
@@ -275,15 +333,17 @@ struct is_convertible_basic_impl
 template <typename From, typename To>
 struct is_convertible_impl
 {
 template <typename From, typename To>
 struct is_convertible_impl
 {
-    typedef typename add_reference<From>::type ref_type;
     enum { value =
         (::boost::type_traits::ice_and<
             ::boost::type_traits::ice_or<
     enum { value =
         (::boost::type_traits::ice_and<
             ::boost::type_traits::ice_or<
-               ::boost::detail::is_convertible_basic_impl<ref_type,To>::value,
+               ::boost::detail::is_convertible_basic_impl<From,To>::value,
                ::boost::is_void<To>::value
             >::value,
             ::boost::type_traits::ice_not<
                ::boost::is_array<To>::value
                ::boost::is_void<To>::value
             >::value,
             ::boost::type_traits::ice_not<
                ::boost::is_array<To>::value
+            >::value,
+            ::boost::type_traits::ice_not<
+               ::boost::is_function<To>::value
             >::value
         >::value) };
 };
             >::value
         >::value) };
 };
@@ -291,15 +351,17 @@ struct is_convertible_impl
 template <typename From, typename To>
 struct is_convertible_impl
 {
 template <typename From, typename To>
 struct is_convertible_impl
 {
-    typedef typename add_reference<From>::type ref_type;
     BOOST_STATIC_CONSTANT(bool, value =
         (::boost::type_traits::ice_and<
             ::boost::type_traits::ice_or<
     BOOST_STATIC_CONSTANT(bool, value =
         (::boost::type_traits::ice_and<
             ::boost::type_traits::ice_or<
-               ::boost::detail::is_convertible_basic_impl<ref_type,To>::value,
+               ::boost::detail::is_convertible_basic_impl<From,To>::value,
                ::boost::is_void<To>::value
             >::value,
             ::boost::type_traits::ice_not<
                ::boost::is_array<To>::value
                ::boost::is_void<To>::value
             >::value,
             ::boost::type_traits::ice_not<
                ::boost::is_array<To>::value
+            >::value,
+            ::boost::type_traits::ice_not<
+               ::boost::is_function<To>::value
             >::value
         >::value)
         );
             >::value
         >::value)
         );
@@ -402,14 +464,14 @@ struct is_convertible_impl_dispatch
 
 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void,To,false)
 
 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void,To,false)
-BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void,true)
+BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void,false)
 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
 BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const,To,false)
 BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void volatile,To,false)
 BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const volatile,To,false)
 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
 BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const,To,false)
 BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void volatile,To,false)
 BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const volatile,To,false)
-BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const,true)
-BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void volatile,true)
-BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const volatile,true)
+BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const,false)
+BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void volatile,false)
+BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const volatile,false)
 #endif
 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
 #endif
 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION