summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/type_traits/is_convertible.hpp')
-rw-r--r--3rdParty/Boost/src/boost/type_traits/is_convertible.hpp165
1 files changed, 114 insertions, 51 deletions
diff --git a/3rdParty/Boost/src/boost/type_traits/is_convertible.hpp b/3rdParty/Boost/src/boost/type_traits/is_convertible.hpp
index 0d42c46..a844cec 100644
--- a/3rdParty/Boost/src/boost/type_traits/is_convertible.hpp
+++ b/3rdParty/Boost/src/boost/type_traits/is_convertible.hpp
@@ -17,20 +17,22 @@
#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/add_lvalue_reference.hpp>
#include <boost/type_traits/add_rvalue_reference.hpp>
+#include <boost/type_traits/is_function.hpp>
#if defined(__MWERKS__)
-#include <boost/type_traits/is_function.hpp>
#include <boost/type_traits/remove_reference.hpp>
#endif
-
+#if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+# include <boost/utility/declval.hpp>
+#endif
#endif // BOOST_IS_CONVERTIBLE
// should be always the last #include directive
@@ -40,7 +42,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
@@ -52,42 +54,43 @@ namespace boost {
namespace detail {
-// MS specific version:
+#if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
-#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
+ // This is a C++11 conforming version, place this first and use it wherever possible:
-// This workaround is necessary to handle when From is void
-// which is normally taken care of by the partial specialization
-// of the is_convertible typename.
-using ::boost::type_traits::yes_type;
-using ::boost::type_traits::no_type;
+# define BOOST_TT_CXX11_IS_CONVERTIBLE
-template< typename From >
-struct does_conversion_exist
-{
- template< typename To > struct result_
- {
- static no_type BOOST_TT_DECL _m_check(...);
- static yes_type BOOST_TT_DECL _m_check(To);
- static typename add_rvalue_reference<From>::type _m_from;
- enum { value = sizeof( _m_check(_m_from) ) == sizeof(yes_type) };
- };
-};
+ template <class A, class B, class C>
+ struct or_helper
+ {
+ static const bool value = (A::value || B::value || C::value);
+ };
-template<>
-struct does_conversion_exist<void>
-{
- template< typename To > struct result_
- {
- enum { value = ::boost::is_void<To>::value };
- };
-};
+ template<typename From, typename To, bool b = or_helper<boost::is_void<From>, boost::is_function<To>, boost::is_array<To> >::value>
+ struct is_convertible_basic_impl
+ {
+ // Nothing converts to function or array, but void converts to void:
+ static const bool value = is_void<To>::value;
+ };
-template <typename From, typename To>
-struct is_convertible_basic_impl
- : public does_conversion_exist<From>::template result_<To>
-{
-};
+ template<typename From, typename To>
+ class is_convertible_basic_impl<From, To, false>
+ {
+ typedef char one;
+ typedef int two;
+
+ template<typename To1>
+ static void test_aux(To1);
+
+ template<typename From1, typename To1>
+ static decltype(test_aux<To1>(boost::declval<From1>()), one()) test(int);
+
+ template<typename, typename>
+ static two test(...);
+
+ public:
+ static const bool value = sizeof(test<From, To>(0)) == 1;
+ };
#elif defined(__BORLANDC__) && (__BORLANDC__ < 0x560)
//
@@ -107,7 +110,7 @@ struct is_convertible_impl
static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(T);
};
- static typename add_rvalue_reference<From>::type _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
@@ -120,6 +123,8 @@ struct is_convertible_impl
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,9 +137,18 @@ template <typename T> struct checker
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_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);
+#endif
};
#elif (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \
@@ -152,6 +166,8 @@ struct is_convertible_basic_impl
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,11 +178,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 typename add_rvalue_reference<From>::type _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)
);
+#endif
};
#elif defined(__DMC__)
@@ -174,6 +198,8 @@ struct is_convertible_basic_impl
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,13 +212,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);
- static typename add_rvalue_reference<From>::type _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.
+#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)
};
+#endif
};
#elif defined(__MWERKS__)
@@ -209,6 +243,9 @@ struct is_convertible_basic_impl_aux;
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,11 +253,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 typename add_rvalue_reference<From>::type _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)
);
+#endif
};
template <typename From, typename To>
@@ -228,10 +273,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 typename add_rvalue_reference<From>::type _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)
);
+#endif
};
template <typename From, typename To>
@@ -243,7 +296,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 (...).
@@ -253,7 +305,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 typename add_rvalue_reference<From>::type _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)
@@ -261,9 +315,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<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)
);
+#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
@@ -276,15 +336,17 @@ struct is_convertible_basic_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<
- ::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
+ >::value,
+ ::boost::type_traits::ice_not<
+ ::boost::is_function<To>::value
>::value
>::value) };
};
@@ -292,15 +354,17 @@ 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::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
+ >::value,
+ ::boost::type_traits::ice_not<
+ ::boost::is_function<To>::value
>::value
>::value)
);
@@ -354,7 +418,8 @@ struct is_convertible_impl_dispatch_base
typedef is_convertible_impl_select<
::boost::is_arithmetic<From>::value,
::boost::is_arithmetic<To>::value,
-#ifndef BOOST_NO_IS_ABSTRACT
+#if !defined(BOOST_NO_IS_ABSTRACT) && !defined(BOOST_TT_CXX11_IS_CONVERTIBLE)
+ // We need to filter out abstract types, only if we don't have a strictly conforming C++11 version:
::boost::is_abstract<To>::value
#else
false
@@ -401,7 +466,6 @@ struct is_convertible_impl_dispatch
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(is_convertible,void,void,true)
#endif // BOOST_NO_CV_VOID_SPECIALIZATIONS
-#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,false)
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
@@ -412,7 +476,6 @@ BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,v
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
} // namespace detail