Add result<U&, E> specialization. Fixes #72.

This commit is contained in:
Peter Dimov
2023-09-12 03:34:24 +03:00
parent a57c568324
commit 951b3fe7b4
22 changed files with 1808 additions and 4 deletions

View File

@@ -181,6 +181,34 @@ int main()
BOOST_TEST_EQ( X::instances, 0 );
//
{
int x = 5;
result<int&> r( x );
result<int const&> r2 = r;
BOOST_TEST( r2 ) && BOOST_TEST_EQ( *r2, 5 );
}
{
int x = 6;
result<int&> const r( x );
result<int const&> r2 = r;
BOOST_TEST( r2 ) && BOOST_TEST_EQ( *r2, 6 );
}
{
int x = 7;
result<int const&> r2 = result<int&>( x );
BOOST_TEST( r2 ) && BOOST_TEST_EQ( *r2, 7 );
}
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<long>, result<int>>));
BOOST_TEST_TRAIT_TRUE((std::is_convertible<result<int>, result<long>>));
@@ -196,6 +224,18 @@ int main()
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int, void*>, result<int, int>>));
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<int, int>, result<int, void*>>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<int const&>, result<int&>>));
BOOST_TEST_TRAIT_TRUE((std::is_convertible<result<int&>, result<int const&>>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&>, result<int>>));
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<int>, result<int const&>>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&>, result<long&>>));
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<long&>, result<int const&>>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&>, result<long const&>>));
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<long const&>, result<int const&>>));
}
return boost::report_errors();