]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/any/test/basic_any_test_large_object.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / any / test / basic_any_test_large_object.cpp
1 // Copyright Ruslan Arutyunyan, 2019-2021.
2 // Copyright Antony Polukhin, 2021-2022.
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7
8 #include <boost/any/basic_any.hpp>
9
10 #include <boost/core/lightweight_test.hpp>
11
12 #include <cassert>
13
14 static int move_ctors_count = 0;
15 static int destructors_count = 0;
16
17 struct A {
18 char a[32];
19
20 A() {}
21 A(const A&) {}
22
23 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
24 A(A&&) BOOST_NOEXCEPT {
25 ++move_ctors_count;
26 }
27 #endif
28
29 ~A() {
30 ++destructors_count;
31 }
32 };
33
34 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
35 template <class T>
36 T&& portable_move(T& value) {
37 return std::move(value);
38 }
39 #else
40 template <class T>
41 T& portable_move(T& value) {
42 return value;
43 }
44 #endif
45
46 int main() {
47 {
48 A a;
49 boost::anys::basic_any<24, 8> any1(a);
50 boost::anys::basic_any<24, 8> any2(portable_move(any1));
51 boost::anys::basic_any<24, 8> any3(portable_move(any2));
52 BOOST_TEST_EQ(move_ctors_count, 0);
53 }
54
55 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
56 BOOST_TEST_EQ(destructors_count, 2);
57 #else
58 BOOST_TEST_EQ(destructors_count, 4);
59 #endif
60
61 return boost::report_errors();
62 }