]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/defer_nested_error_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/on_error.hpp>
7 #include <boost/leaf/handle_errors.hpp>
8 #include <boost/leaf/result.hpp>
9 #include "lightweight_test.hpp"
11 namespace leaf
= boost::leaf
;
21 auto load
= leaf::on_error( [] { return info
<0>{0}; } );
22 return leaf::new_error( info
<2>{2} );
27 auto load
= leaf::on_error( [] { return info
<0>{-1}; }, [] { return info
<1>{1}; }, [] { return info
<2>{-1}; } );
33 return f1().load( info
<3>{3} );
38 int r
= leaf::try_handle_all(
39 []() -> leaf::result
<int>
43 []( info
<0> i0
, info
<1> i1
, info
<2> i2
, info
<3> i3
)
45 BOOST_TEST_EQ(i0
.value
, 0);
46 BOOST_TEST_EQ(i1
.value
, 1);
47 BOOST_TEST_EQ(i2
.value
, 2);
48 BOOST_TEST_EQ(i3
.value
, 3);
57 return boost::report_errors();