]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/exception_to_result_test.cpp
1 // Copyright (c) 2018-2020 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/detail/config.hpp>
7 #ifdef BOOST_LEAF_NO_EXCEPTIONS
13 std::cout
<< "Unit test not applicable." << std::endl
;
19 #include <boost/leaf/capture.hpp>
20 #include <boost/leaf/result.hpp>
21 #include <boost/leaf/handle_errors.hpp>
22 #include "lightweight_test.hpp"
24 namespace leaf
= boost::leaf
;
26 template <int> struct my_exception
: std::exception
{ };
31 int r
= leaf::try_handle_all(
34 return leaf::exception_to_result
<my_exception
<1>,my_exception
<2>>(
37 throw my_exception
<1>();
40 []( my_exception
<1> const &, std::exception_ptr
const & ep
)
44 std::rethrow_exception(ep
);
46 catch( my_exception
<1> const & )
51 []( my_exception
<2> const & )
62 int r
= leaf::try_handle_all(
65 return leaf::exception_to_result
<my_exception
<1>,my_exception
<2>>(
68 throw my_exception
<2>();
71 []( my_exception
<1> const & )
75 []( my_exception
<2> const &, std::exception_ptr
const & ep
)
79 std::rethrow_exception(ep
);
81 catch( my_exception
<2> const & )
93 int r
= leaf::try_handle_all(
96 return leaf::exception_to_result
<std::exception
,my_exception
<1>>(
99 throw my_exception
<1>();
102 []( std::exception
const &, std::exception_ptr
const & ep
)
106 std::rethrow_exception(ep
);
108 catch( my_exception
<1> const & )
113 []( my_exception
<1> const & )
123 return boost::report_errors();