]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/result_implicit_conversion_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / leaf / test / result_implicit_conversion_test.cpp
1 // Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
2
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)
5
6 #ifdef BOOST_LEAF_TEST_SINGLE_HEADER
7 # include "leaf.hpp"
8 #else
9 # include <boost/leaf/result.hpp>
10 #endif
11
12 #include "lightweight_test.hpp"
13
14 namespace leaf = boost::leaf;
15
16 struct A
17 {
18 int x;
19 A() noexcept:
20 x(0)
21 {
22 }
23
24 A( int x ) noexcept:
25 x(x)
26 {
27 }
28 };
29
30 leaf::result<int> f()
31 {
32 return 42;
33 }
34
35 leaf::result<A> g()
36 {
37 return f();
38 }
39
40 int main()
41 {
42 BOOST_TEST_EQ(g().value().x, 42);
43 {
44 leaf::result<int> r1(42);
45 leaf::result<A> r2(std::move(r1));
46 BOOST_TEST_EQ(r2.value().x, 42);
47 }
48 {
49 leaf::result<int> r1(42);
50 leaf::result<A> r2;
51 r2 = std::move(r1);
52 BOOST_TEST_EQ(r2.value().x, 42);
53 }
54 return boost::report_errors();
55 }