X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Ftype_traits%2Fis_convertible.hpp;h=3eccadc588cc7142320b022ce9c514ccb3bd62fa;hp=c05c297eaf9b8208c081aeec63e4c49ef52db9e6;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/type_traits/is_convertible.hpp b/boost/type_traits/is_convertible.hpp index c05c297..3eccadc 100644 --- a/boost/type_traits/is_convertible.hpp +++ b/boost/type_traits/is_convertible.hpp @@ -17,16 +17,17 @@ #include #include #include -#include #include #include #include #ifndef BOOST_NO_IS_ABSTRACT #include #endif +#include +#include +#include #if defined(__MWERKS__) -#include #include #endif @@ -39,7 +40,7 @@ namespace boost { #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 @@ -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 From _m_from; + static typename add_lvalue_reference::type _m_from; enum { value = sizeof( _m_check(_m_from) ) == sizeof(yes_type) }; }; }; @@ -84,7 +85,7 @@ struct does_conversion_exist template struct is_convertible_basic_impl - : does_conversion_exist::template result_ + : public does_conversion_exist::template result_ { }; @@ -106,7 +107,7 @@ struct is_convertible_impl static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(T); }; - static From _m_from; + static typename add_lvalue_reference::type _m_from; static bool const value = sizeof( checker::_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 any_conversion(const volatile T&); + template any_conversion(const T&); + template any_conversion(volatile T&); template any_conversion(T&); }; @@ -131,9 +134,18 @@ template struct checker template struct is_convertible_basic_impl { - static From _m_from; - static bool const value = sizeof( boost::detail::checker::_m_check(_m_from, 0) ) + typedef typename add_lvalue_reference::type lvalue_type; + typedef typename add_rvalue_reference::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::_m_check(static_cast(_m_from), 0) ) + == sizeof(::boost::type_traits::yes_type); +#else + static bool const value = + sizeof( boost::detail::checker::_m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type); +#endif }; #elif (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \ @@ -151,6 +163,8 @@ struct is_convertible_basic_impl struct any_conversion { template any_conversion(const volatile T&); + template any_conversion(const T&); + template any_conversion(volatile T&); // we need this constructor to catch references to functions // (which can not be cv-qualified): template 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 From _m_from; + typedef typename add_lvalue_reference::type lvalue_type; + typedef typename add_rvalue_reference::type rvalue_type; + static lvalue_type _m_from; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_CONSTANT(bool, value = + sizeof( _m_check(static_cast(_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) ); +#endif }; #elif defined(__DMC__) @@ -173,6 +195,8 @@ struct is_convertible_basic_impl struct any_conversion { template any_conversion(const volatile T&); + template any_conversion(const T&); + template any_conversion(volatile T&); // we need this constructor to catch references to functions // (which can not be cv-qualified): template any_conversion(T&); @@ -185,13 +209,21 @@ struct is_convertible_basic_impl template 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::type lvalue_type; + typedef typename add_rvalue_reference::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. +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + enum { value = + sizeof( _m_check(static_cast(_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) }; +#endif }; #elif defined(__MWERKS__) @@ -208,6 +240,9 @@ struct is_convertible_basic_impl_aux; struct any_conversion { template any_conversion(const volatile T&); + template any_conversion(const T&); + template any_conversion(volatile T&); + template any_conversion(T&); }; template @@ -215,11 +250,19 @@ struct is_convertible_basic_impl_aux { 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::type lvalue_type; + typedef typename add_rvalue_reference::type rvalue_type; + static lvalue_type _m_from; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_CONSTANT(bool, value = + sizeof( _m_check(static_cast(_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) ); +#endif }; template @@ -227,10 +270,18 @@ struct is_convertible_basic_impl_aux { 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::type lvalue_type; + typedef typename add_rvalue_reference::type rvalue_type; + static lvalue_type _m_from; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_CONSTANT(bool, value = + sizeof( _m_check(static_cast(_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) ); +#endif }; template @@ -242,7 +293,6 @@ struct is_convertible_basic_impl: {}; #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 (...). @@ -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 From _m_from; + typedef typename add_lvalue_reference::type lvalue_type; + typedef typename add_rvalue_reference::type rvalue_type; + static lvalue_type _m_from; #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 +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_CONSTANT(bool, value = + sizeof( _m_check(static_cast(_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) ); +#endif #ifdef BOOST_MSVC #pragma warning(pop) #endif @@ -275,15 +333,17 @@ struct is_convertible_basic_impl template struct is_convertible_impl { - typedef typename add_reference::type ref_type; enum { value = (::boost::type_traits::ice_and< ::boost::type_traits::ice_or< - ::boost::detail::is_convertible_basic_impl::value, + ::boost::detail::is_convertible_basic_impl::value, ::boost::is_void::value >::value, ::boost::type_traits::ice_not< ::boost::is_array::value + >::value, + ::boost::type_traits::ice_not< + ::boost::is_function::value >::value >::value) }; }; @@ -291,15 +351,17 @@ struct is_convertible_impl template struct is_convertible_impl { - typedef typename add_reference::type ref_type; BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_and< ::boost::type_traits::ice_or< - ::boost::detail::is_convertible_basic_impl::value, + ::boost::detail::is_convertible_basic_impl::value, ::boost::is_void::value >::value, ::boost::type_traits::ice_not< ::boost::is_array::value + >::value, + ::boost::type_traits::ice_not< + ::boost::is_function::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) -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) -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