forked from boostorg/type_traits
Change is_convertible to use C++0x behaviour where possible.
Change is_converible to use MSVC __is_convertible intrinsic. Fixes #5271. Fixes #4530. [SVN r69822]
This commit is contained in:
1 parent
104afb9ba4
commit
ee29b7660f
111 files changed
+124
-163
No files matched your search
@@ -87,6 +87,7 @@ bool declval_bool(){return true;}
|
||||
|
||||
TT_TEST_BEGIN(common_type)
|
||||
{
|
||||
#ifndef __SUNPRO_CC
|
||||
assignation_2<C1C2, C1>();
|
||||
typedef tt::common_type<C1C2&, C1&>::type T1;
|
||||
typedef tt::common_type<C3*, C2*>::type T2;
|
||||
@@ -105,6 +106,10 @@ TT_TEST_BEGIN(common_type)
|
||||
assignation_3<C2, C1C2, C1>();
|
||||
assignation_3<C1C2, C2, C1>();
|
||||
//assignation_3<C1, C2, C1C2>(); // fails because the common type is the third
|
||||
#endif
|
||||
|
||||
typedef tt::common_type<C1C2, C1>::type t1;
|
||||
BOOST_CHECK_TYPE(t1, C1C2);
|
||||
|
||||
BOOST_CHECK_TYPE(tt::common_type<int>::type, int);
|
||||
BOOST_CHECK_TYPE(tt::common_type<char>::type, char);
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#else
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
#endif
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
|
||||
template <class T>
|
||||
struct convertible_from
|
||||
@@ -22,6 +24,37 @@ struct base2 { };
|
||||
struct middle2 : public virtual base2 { };
|
||||
struct derived2 : public middle2 { };
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
|
||||
template<typename T>
|
||||
struct test_bug_4530
|
||||
{
|
||||
template<typename A>
|
||||
test_bug_4530(A&&, typename boost::enable_if<boost::is_convertible<A&&, T> >::type* =0);
|
||||
};
|
||||
|
||||
struct A4530
|
||||
{
|
||||
template <class T>
|
||||
A4530(T);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
|
||||
struct bug_5271a
|
||||
{
|
||||
__declspec(align(16)) int value;
|
||||
};
|
||||
|
||||
struct bug_5271b
|
||||
{
|
||||
__declspec(align(16)) int value;
|
||||
bug_5271b(int v) : value(v) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(is_convertible)
|
||||
|
||||
@@ -49,7 +82,7 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int,test_abc1>::value), fals
|
||||
#endif
|
||||
|
||||
// The following four do not compile without member template support:
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,void>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,void>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<void,void>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<void,float>::value), false);
|
||||
|
||||
@@ -102,7 +135,12 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<test_abc1&, test_abc2>::valu
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int, int_constructible>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<float> >::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<float const&> >::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<float&> >::value), true);
|
||||
//
|
||||
// These two tests give different results with different compilers, we used to require *true* results
|
||||
// from these, but C++0x behaviour requires *false*:
|
||||
//
|
||||
//BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<float&> >::value), false);
|
||||
//BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<char,convertible_from<char&> >::value), false);
|
||||
|
||||
#if !(defined(__GNUC__) && (__GNUC__ < 4))
|
||||
// GCC 3.x emits warnings here, which causes the tests to fail when we compile with warnings-as-errors:
|
||||
@@ -113,7 +151,6 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<char&
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<char,convertible_from<char> >::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<char,convertible_from<char const&> >::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<char,convertible_from<char&> >::value), true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float&,convertible_from<float> >::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float const&,convertible_from<float> >::value), true);
|
||||
@@ -140,13 +177,15 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<__int64,char>::value), true)
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<__int64,float>::value), true);
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
// Test bug case 4530:
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<test_bug_4530<A4530>,A4530>::value), true);
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int, bug_5271a>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int, bug_5271b>::value), true);
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user