Add SFINAE conditions

This commit is contained in:
Peter Dimov committed 2017-05-31 07:42:45 +03:00
1 parent abb7b551cc
commit 7d25e131be
6 files changed
+115 -21

No files matched your search

+26
View File
@@ -57,6 +57,11 @@ STATIC_ASSERT( !std::is_nothrow_move_constructible<X2>::value );
STATIC_ASSERT( !std::is_nothrow_copy_assignable<X2>::value );
STATIC_ASSERT( !std::is_nothrow_move_assignable<X2>::value );
struct Y
{
Y& operator=( Y const& ) = delete;
};
int main()
{
{
@@ -164,5 +169,26 @@ int main()
BOOST_TEST_EQ( get<0>(v).v, 4 );
}
{
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_copy_assignable<variant<int>>));
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_copy_assignable<variant<int, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_copy_assignable<variant<int, float>>));
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_copy_assignable<variant<int, int, float, float>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_assignable<variant<X1>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_assignable<variant<X1, int>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_assignable<variant<X1, int, float>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_assignable<variant<int, X1>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_assignable<variant<int, int, X1>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_assignable<variant<X1, X2>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_assignable<variant<X1, X2, int, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_copy_assignable<variant<X1, X2>>));
BOOST_TEST_TRAIT_FALSE((std::is_copy_assignable<variant<int const>>));
BOOST_TEST_TRAIT_FALSE((std::is_copy_assignable<variant<int, float, Y>>));
}
return boost::report_errors();
}
+8
View File
@@ -43,6 +43,11 @@ STATIC_ASSERT( !std::is_nothrow_default_constructible<X2>::value );
STATIC_ASSERT( !std::is_nothrow_copy_constructible<X2>::value );
STATIC_ASSERT( !std::is_nothrow_move_constructible<X2>::value );
struct Y
{
Y( Y const& ) = delete;
};
template<class V> static void test( V const & v )
{
V v2( v );
@@ -114,6 +119,9 @@ int main()
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_constructible<variant<X1, X2>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_copy_constructible<variant<X1, X2, int, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_copy_constructible<variant<X1, X2>>));
BOOST_TEST_TRAIT_FALSE((std::is_copy_constructible<variant<int, float, Y>>));
}
return boost::report_errors();
+8
View File
@@ -20,6 +20,11 @@ struct X
X();
};
struct Y
{
Y() = delete;
};
int main()
{
{
@@ -89,6 +94,9 @@ int main()
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_default_constructible<variant<X>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_default_constructible<variant<X, int>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_default_constructible<variant<X, int, float>>));
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<variant<int, Y>>));
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<variant<Y, int>>));
}
return boost::report_errors();
+26
View File
@@ -57,6 +57,11 @@ STATIC_ASSERT( !std::is_nothrow_move_constructible<X2>::value );
STATIC_ASSERT( !std::is_nothrow_copy_assignable<X2>::value );
STATIC_ASSERT( !std::is_nothrow_move_assignable<X2>::value );
struct Y
{
Y& operator=( Y&& ) = delete;
};
int main()
{
{
@@ -164,5 +169,26 @@ int main()
BOOST_TEST_EQ( get<0>(v).v, 4 );
}
{
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_move_assignable<variant<int>>));
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_move_assignable<variant<int, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_move_assignable<variant<int, float>>));
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_move_assignable<variant<int, int, float, float>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_assignable<variant<X1>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_assignable<variant<X1, int>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_assignable<variant<X1, int, float>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_assignable<variant<int, X1>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_assignable<variant<int, int, X1>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_assignable<variant<X1, X2>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_assignable<variant<X1, X2, int, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_move_assignable<variant<X1, X2>>));
BOOST_TEST_TRAIT_FALSE((std::is_move_assignable<variant<int const>>));
BOOST_TEST_TRAIT_FALSE((std::is_move_assignable<variant<int, float, Y>>));
}
return boost::report_errors();
}
+8
View File
@@ -43,6 +43,11 @@ STATIC_ASSERT( !std::is_nothrow_default_constructible<X2>::value );
STATIC_ASSERT( !std::is_nothrow_copy_constructible<X2>::value );
STATIC_ASSERT( !std::is_nothrow_move_constructible<X2>::value );
struct Y
{
Y( Y&& ) = delete;
};
template<class V> static void test( V&& v )
{
V v2( v );
@@ -115,6 +120,9 @@ int main()
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_constructible<variant<X1, X2>>));
BOOST_TEST_TRAIT_FALSE((std::is_nothrow_move_constructible<variant<X1, X2, int, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_move_constructible<variant<X1, X2>>));
BOOST_TEST_TRAIT_FALSE((std::is_move_constructible<variant<int, float, Y>>));
}
return boost::report_errors();