forked from boostorg/type_traits
Remove stray ; in test file.
Add some rvalue ref tests for is_convertible. Enable use of intrinsics for Intel on Win32. Fix rvalue ref usage in is_convertible. [SVN r79983]
This commit is contained in:
@@ -79,7 +79,8 @@
|
||||
# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MSVC) && defined(BOOST_MSVC_FULL_VER) && (BOOST_MSVC_FULL_VER >=140050215)
|
||||
#if (defined(BOOST_MSVC) && defined(BOOST_MSVC_FULL_VER) && (BOOST_MSVC_FULL_VER >=140050215))\
|
||||
|| (defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1500))
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
|
||||
# define BOOST_IS_UNION(T) __is_union(T)
|
||||
@@ -221,6 +222,11 @@
|
||||
# define BOOST_ALIGNMENT_OF(T) __alignof__(T)
|
||||
# endif
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
# include <type_traits>
|
||||
# define BOOST_IS_CONVERTIBLE(T,U) (std::is_convertible<T, U>::value)
|
||||
#endif
|
||||
|
||||
# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
|
||||
#endif
|
||||
|
||||
|
||||
@@ -120,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&);
|
||||
};
|
||||
|
||||
@@ -132,8 +134,9 @@ 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_rvalue_reference<From>::type rvalue_type;
|
||||
static From _m_from;
|
||||
static bool const value = sizeof( boost::detail::checker<To>::_m_check(static_cast<rvalue_type>(_m_from), 0) )
|
||||
== sizeof(::boost::type_traits::yes_type);
|
||||
};
|
||||
|
||||
@@ -152,6 +155,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,10 +167,11 @@ 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_rvalue_reference<From>::type rvalue_type;
|
||||
static From _m_from;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
|
||||
sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0) ) == sizeof(::boost::type_traits::yes_type)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -174,6 +180,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,12 +194,13 @@ 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_rvalue_reference<From>::type rvalue_type;
|
||||
static From _m_from;
|
||||
|
||||
// Static constants sometime cause the conversion of _m_from to To to be
|
||||
// called. This doesn't happen with an enum.
|
||||
enum { value =
|
||||
sizeof( _m_check(_m_from, 0, 0) ) == sizeof(::boost::type_traits::yes_type)
|
||||
sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0, 0) ) == sizeof(::boost::type_traits::yes_type)
|
||||
};
|
||||
};
|
||||
|
||||
@@ -209,6 +218,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,10 +228,11 @@ 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_rvalue_reference<From>::type rvalue_type;
|
||||
static From _m_from;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
|
||||
sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0) ) == sizeof(::boost::type_traits::yes_type)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -228,9 +241,10 @@ 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_rvalue_reference<From>::type rvalue_type;
|
||||
static From _m_from;
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
|
||||
sizeof( _m_check(static_cast<rvalue_type>(_m_from)) ) == sizeof(::boost::type_traits::yes_type)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -243,7 +257,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 +266,8 @@ 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_rvalue_reference<From>::type rvalue_type;
|
||||
static From _m_from;
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4244)
|
||||
@@ -262,7 +276,7 @@ struct is_convertible_basic_impl
|
||||
#endif
|
||||
#endif
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
|
||||
sizeof( _m_check(static_cast<rvalue_type>(_m_from)) ) == sizeof(::boost::type_traits::yes_type)
|
||||
);
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -102,6 +102,8 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<const int*, int[3]>::value),
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<const int&, int>::value), true);
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<const int&&, int>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int&&, const int&>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int, int&>::value), false);
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(&)[4], const int*>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(&)(int), int(*)(int)>::value), true);
|
||||
|
||||
+1
-1
@@ -260,7 +260,7 @@ struct nothrow_copy_UDT
|
||||
{
|
||||
nothrow_copy_UDT();
|
||||
nothrow_copy_UDT(const nothrow_copy_UDT&)throw();
|
||||
~nothrow_copy_UDT(){};
|
||||
~nothrow_copy_UDT(){}
|
||||
nothrow_copy_UDT& operator=(const nothrow_copy_UDT&);
|
||||
bool operator==(const nothrow_copy_UDT&)const
|
||||
{ return true; }
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
# include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
# include <boost/type_traits/is_rvalue_reference.hpp>
|
||||
# include <boost/type_traits/is_reference.hpp>
|
||||
@@ -20,6 +21,7 @@ TT_TEST_BEGIN(rvalue_reference_test)
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_reference<int (&&)(int)>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_rvalue_reference<int (&)(int)>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_rvalue_reference<int (&&)(int)>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int&&, int&>::value), false);
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
Reference in New Issue
Block a user