From ed6115361006240e3c7b02295599e4534cc55a13 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 19 Oct 2013 08:57:20 +0200 Subject: Update internal Boost subset to 1.54.0 --- cutl/details/boost/type_traits/is_convertible.hpp | 106 +++++++++++++++++----- 1 file changed, 84 insertions(+), 22 deletions(-) (limited to 'cutl/details/boost/type_traits/is_convertible.hpp') diff --git a/cutl/details/boost/type_traits/is_convertible.hpp b/cutl/details/boost/type_traits/is_convertible.hpp index 8c7bf19..6f0a110 100644 --- a/cutl/details/boost/type_traits/is_convertible.hpp +++ b/cutl/details/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 cutl_details_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 ::cutl_details_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(::cutl_details_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( cutl_details_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( cutl_details_boost::detail::checker::_m_check(static_cast(_m_from), 0) ) + == sizeof(::cutl_details_boost::type_traits::yes_type); +#else + static bool const value = + sizeof( cutl_details_boost::detail::checker::_m_check(_m_from, 0) ) == sizeof(::cutl_details_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 ::cutl_details_boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion ...); static ::cutl_details_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(::cutl_details_boost::type_traits::yes_type) + ); +#else BOOST_STATIC_CONSTANT(bool, value = sizeof( _m_check(_m_from, 0) ) == sizeof(::cutl_details_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 ::cutl_details_boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion, float, T); static ::cutl_details_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(::cutl_details_boost::type_traits::yes_type) + }; +#else enum { value = sizeof( _m_check(_m_from, 0, 0) ) == sizeof(::cutl_details_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 ::cutl_details_boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion ...); static ::cutl_details_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(::cutl_details_boost::type_traits::yes_type) + ); +#else BOOST_STATIC_CONSTANT(bool, value = sizeof( _m_check(_m_from, 0) ) == sizeof(::cutl_details_boost::type_traits::yes_type) ); +#endif }; template @@ -227,10 +270,18 @@ struct is_convertible_basic_impl_aux { static ::cutl_details_boost::type_traits::no_type BOOST_TT_DECL _m_check(...); static ::cutl_details_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(::cutl_details_boost::type_traits::yes_type) + ); +#else BOOST_STATIC_CONSTANT(bool, value = sizeof( _m_check(_m_from) ) == sizeof(::cutl_details_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 ::cutl_details_boost::type_traits::no_type BOOST_TT_DECL _m_check(...); static ::cutl_details_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(::cutl_details_boost::type_traits::yes_type) + ); +#else BOOST_STATIC_CONSTANT(bool, value = sizeof( _m_check(_m_from) ) == sizeof(::cutl_details_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 = (::cutl_details_boost::type_traits::ice_and< ::cutl_details_boost::type_traits::ice_or< - ::cutl_details_boost::detail::is_convertible_basic_impl::value, + ::cutl_details_boost::detail::is_convertible_basic_impl::value, ::cutl_details_boost::is_void::value >::value, ::cutl_details_boost::type_traits::ice_not< ::cutl_details_boost::is_array::value + >::value, + ::cutl_details_boost::type_traits::ice_not< + ::cutl_details_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 = (::cutl_details_boost::type_traits::ice_and< ::cutl_details_boost::type_traits::ice_or< - ::cutl_details_boost::detail::is_convertible_basic_impl::value, + ::cutl_details_boost::detail::is_convertible_basic_impl::value, ::cutl_details_boost::is_void::value >::value, ::cutl_details_boost::type_traits::ice_not< ::cutl_details_boost::is_array::value + >::value, + ::cutl_details_boost::type_traits::ice_not< + ::cutl_details_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 -- cgit v1.1