Add value_type, error_type typedefs to result. Refs #93.

This commit is contained in:
Peter Dimov
2022-09-26 21:01:49 +03:00
parent 53c00841fc
commit 52d7429473
4 changed files with 34 additions and 0 deletions

View File

@ -95,6 +95,11 @@ private:
variant2::variant<T, E> v_;
public:
using value_type = T;
using error_type = E;
public:
// constructors
@ -444,6 +449,11 @@ private:
variant2::variant<variant2::monostate, E> v_;
public:
using value_type = void;
using error_type = E;
public:
// constructors

View File

@ -149,3 +149,4 @@ boost_test(TYPE run SOURCES result_range_for.cpp)
boost_test(TYPE run SOURCES result_value_construct2.cpp)
boost_test(TYPE run SOURCES result_error_construct2.cpp)
boost_test(TYPE run SOURCES result_convert_construct.cpp)
boost_test(TYPE run SOURCES result_typedefs.cpp)

View File

@ -180,3 +180,4 @@ run result_value_construct2.cpp : : : $(CPP11) ;
run result_error_construct2.cpp : : : $(CPP11) ;
run result_errc_construct.cpp : : : $(CPP11) ;
run result_convert_construct.cpp : : : $(CPP11) ;
run result_typedefs.cpp : : : $(CPP11) ;

22
test/result_typedefs.cpp Normal file
View File

@ -0,0 +1,22 @@
// Copyright 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/result.hpp>
#include <boost/core/lightweight_test_trait.hpp>
using namespace boost::system;
struct X {};
int main()
{
BOOST_TEST_TRAIT_SAME( result<int>::value_type, int );
BOOST_TEST_TRAIT_SAME( result<X>::value_type, X );
BOOST_TEST_TRAIT_SAME( result<void>::value_type, void );
BOOST_TEST_TRAIT_SAME( result<int>::error_type, error_code );
BOOST_TEST_TRAIT_SAME( result<int, X>::error_type, X );
return boost::report_errors();
}