]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/exception_to_result_test.cpp
1 // Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/leaf/config.hpp>
8 #ifdef BOOST_LEAF_NO_EXCEPTIONS
14 std::cout
<< "Unit test not applicable." << std::endl
;
20 #ifdef BOOST_LEAF_TEST_SINGLE_HEADER
23 # include <boost/leaf/exception.hpp>
24 # include <boost/leaf/result.hpp>
25 # include <boost/leaf/handle_errors.hpp>
28 #include "lightweight_test.hpp"
30 namespace leaf
= boost::leaf
;
32 template <int> struct my_exception
: std::exception
{ };
37 int r
= leaf::try_handle_all(
40 return leaf::exception_to_result
<my_exception
<1>,my_exception
<2>>(
43 throw my_exception
<1>();
46 []( my_exception
<1> const &, std::exception_ptr
const & ep
)
50 std::rethrow_exception(ep
);
52 catch( my_exception
<1> const & )
57 []( my_exception
<2> const & )
68 int r
= leaf::try_handle_all(
71 return leaf::exception_to_result
<my_exception
<1>,my_exception
<2>>(
74 throw my_exception
<2>();
77 []( my_exception
<1> const & )
81 []( my_exception
<2> const &, std::exception_ptr
const & ep
)
85 std::rethrow_exception(ep
);
87 catch( my_exception
<2> const & )
99 int r
= leaf::try_handle_all(
102 return leaf::exception_to_result
<std::exception
,my_exception
<1>>(
105 throw my_exception
<1>();
108 []( std::exception
const &, std::exception_ptr
const & ep
)
112 std::rethrow_exception(ep
);
114 catch( my_exception
<1> const & )
119 []( my_exception
<1> const & )
129 return boost::report_errors();