mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 20:47:14 +02:00
Add value_type, error_type typedefs to result. Refs #93.
This commit is contained in:
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
22
test/result_typedefs.cpp
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user