]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/preload_nested_success_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
;
13 struct info
{ int value
; };
15 leaf::result
<void> g1()
17 auto load
= leaf::on_error( info
{1} );
21 leaf::result
<void> g2()
23 return leaf::new_error();
26 leaf::result
<void> f()
28 auto load
= leaf::on_error( info
{2} );
29 BOOST_LEAF_CHECK(g1());
35 int r
= leaf::try_handle_all(
36 []() -> leaf::result
<int>
38 BOOST_LEAF_CHECK(f());
43 BOOST_TEST_EQ(x
.value
, 2);
52 return boost::report_errors();