aboutsummaryrefslogtreecommitdiff
path: root/cutl/details/boost/type_traits/is_convertible.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'cutl/details/boost/type_traits/is_convertible.hpp')
-rw-r--r--cutl/details/boost/type_traits/is_convertible.hpp106
1 files changed, 84 insertions, 22 deletions
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 <cutl/details/boost/type_traits/detail/yes_no_type.hpp>
#include <cutl/details/boost/type_traits/config.hpp>
#include <cutl/details/boost/type_traits/is_array.hpp>
-#include <cutl/details/boost/type_traits/add_reference.hpp>
#include <cutl/details/boost/type_traits/ice.hpp>
#include <cutl/details/boost/type_traits/is_arithmetic.hpp>
#include <cutl/details/boost/type_traits/is_void.hpp>
#ifndef BOOST_NO_IS_ABSTRACT
#include <cutl/details/boost/type_traits/is_abstract.hpp>
#endif
+#include <cutl/details/boost/type_traits/add_lvalue_reference.hpp>
+#include <cutl/details/boost/type_traits/add_rvalue_reference.hpp>
+#include <cutl/details/boost/type_traits/is_function.hpp>
#if defined(__MWERKS__)
-#include <cutl/details/boost/type_traits/is_function.hpp>
#include <cutl/details/boost/type_traits/remove_reference.hpp>
#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<From>::type _m_from;
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
- : does_conversion_exist<From>::template result_<To>
+ : public does_conversion_exist<From>::template result_<To>
{
};
@@ -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<From>::type _m_from;
static bool const value = sizeof( checker<To>::_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 <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&);
};
@@ -131,9 +134,18 @@ template <typename T> struct checker
template <typename From, typename To>
struct is_convertible_basic_impl
{
- static From _m_from;
- static bool const value = sizeof( cutl_details_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( cutl_details_boost::detail::checker<To>::_m_check(static_cast<rvalue_type>(_m_from), 0) )
+ == sizeof(::cutl_details_boost::type_traits::yes_type);
+#else
+ static bool const value =
+ sizeof( cutl_details_boost::detail::checker<To>::_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 <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&);
@@ -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<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(::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 <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&);
@@ -185,13 +209,21 @@ struct is_convertible_basic_impl
template <class T>
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<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(::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 <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>
@@ -215,11 +250,19 @@ struct is_convertible_basic_impl_aux<From,To,false /*FromIsFunctionRef*/>
{
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<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(::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 <typename From, typename To>
@@ -227,10 +270,18 @@ struct is_convertible_basic_impl_aux<From,To,true /*FromIsFunctionRef*/>
{
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<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(::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 <typename From, typename To>
@@ -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<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)
@@ -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<rvalue_type>(_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 <typename From, typename To>
struct is_convertible_impl
{
- typedef typename add_reference<From>::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<ref_type,To>::value,
+ ::cutl_details_boost::detail::is_convertible_basic_impl<From,To>::value,
::cutl_details_boost::is_void<To>::value
>::value,
::cutl_details_boost::type_traits::ice_not<
::cutl_details_boost::is_array<To>::value
+ >::value,
+ ::cutl_details_boost::type_traits::ice_not<
+ ::cutl_details_boost::is_function<To>::value
>::value
>::value) };
};
@@ -291,15 +351,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 =
(::cutl_details_boost::type_traits::ice_and<
::cutl_details_boost::type_traits::ice_or<
- ::cutl_details_boost::detail::is_convertible_basic_impl<ref_type,To>::value,
+ ::cutl_details_boost::detail::is_convertible_basic_impl<From,To>::value,
::cutl_details_boost::is_void<To>::value
>::value,
::cutl_details_boost::type_traits::ice_not<
::cutl_details_boost::is_array<To>::value
+ >::value,
+ ::cutl_details_boost::type_traits::ice_not<
+ ::cutl_details_boost::is_function<To>::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