2021-09-16 18:47:05 +03:00
|
|
|
// Copyright 2017, 2021 Peter Dimov.
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
// https://www.boost.org/LICENSE_1_0.txt
|
|
|
|
|
2021-09-16 18:56:35 +03:00
|
|
|
#include <boost/system/result.hpp>
|
2021-09-16 18:47:05 +03:00
|
|
|
#include <boost/core/lightweight_test.hpp>
|
|
|
|
#include <boost/core/lightweight_test_trait.hpp>
|
|
|
|
|
2021-09-16 18:56:35 +03:00
|
|
|
using namespace boost::system;
|
2021-09-16 18:47:05 +03:00
|
|
|
|
|
|
|
struct X
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2022-07-26 21:35:33 +03:00
|
|
|
struct Y
|
|
|
|
{
|
|
|
|
Y( int );
|
|
|
|
};
|
|
|
|
|
2021-09-16 18:47:05 +03:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result<int> r;
|
|
|
|
|
|
|
|
BOOST_TEST( r.has_value() );
|
|
|
|
BOOST_TEST( !r.has_error() );
|
|
|
|
|
|
|
|
BOOST_TEST_EQ( r.value(), 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
result<X> r;
|
|
|
|
|
|
|
|
BOOST_TEST( r.has_value() );
|
|
|
|
BOOST_TEST( !r.has_error() );
|
|
|
|
}
|
|
|
|
|
2021-09-17 19:22:15 +03:00
|
|
|
{
|
|
|
|
result<void> r;
|
|
|
|
|
|
|
|
BOOST_TEST( r.has_value() );
|
|
|
|
BOOST_TEST( !r.has_error() );
|
|
|
|
}
|
|
|
|
|
2022-07-26 21:35:33 +03:00
|
|
|
{
|
|
|
|
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<int>>));
|
|
|
|
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<int, int>>));
|
|
|
|
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<X>>));
|
|
|
|
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<X, int>>));
|
|
|
|
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<void>>));
|
|
|
|
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<void, int>>));
|
|
|
|
|
|
|
|
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<Y>>));
|
|
|
|
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<Y, int>>));
|
2023-09-12 03:34:24 +03:00
|
|
|
|
|
|
|
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<int&>>));
|
|
|
|
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<int&, int>>));
|
2022-07-26 21:35:33 +03:00
|
|
|
}
|
|
|
|
|
2021-09-16 18:47:05 +03:00
|
|
|
return boost::report_errors();
|
|
|
|
}
|