]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/test/support/unused.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / fusion / test / support / unused.cpp
1 /*=============================================================================
2 Copyright (c) 2018 Kohei Takahashi
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7
8 #include <boost/config.hpp>
9 #include <boost/fusion/support/unused.hpp>
10 #include <boost/type_traits/detail/yes_no_type.hpp>
11 #include <boost/static_assert.hpp>
12 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
13 #include <utility>
14 #endif
15
16 struct T { };
17
18 void unused_construction()
19 {
20 boost::fusion::unused_type dephault;
21
22 boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED parenthesis = boost::fusion::unused_type();
23 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
24 boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED brace{};
25 boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED list_copy = {};
26 #endif
27
28 boost::fusion::unused_type copy_copy BOOST_ATTRIBUTE_UNUSED = dephault;
29 boost::fusion::unused_type copy_direct BOOST_ATTRIBUTE_UNUSED (dephault);
30 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
31 boost::fusion::unused_type copy_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {dephault};
32 boost::fusion::unused_type copy_direct_brace BOOST_ATTRIBUTE_UNUSED {dephault};
33 #endif
34
35 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
36 boost::fusion::unused_type move_copy BOOST_ATTRIBUTE_UNUSED = std::move(dephault);
37 boost::fusion::unused_type move_direct BOOST_ATTRIBUTE_UNUSED (std::move(dephault));
38 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
39 boost::fusion::unused_type move_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {std::move(dephault)};
40 boost::fusion::unused_type move_direct_brace BOOST_ATTRIBUTE_UNUSED {std::move(dephault)};
41 #endif
42 #endif
43
44
45 T value;
46
47 boost::fusion::unused_type T_copy_copy BOOST_ATTRIBUTE_UNUSED = value;
48 boost::fusion::unused_type T_copy_direct BOOST_ATTRIBUTE_UNUSED (value);
49 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
50 boost::fusion::unused_type T_copy_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {value};
51 boost::fusion::unused_type T_copy_direct_brace BOOST_ATTRIBUTE_UNUSED {value};
52 #endif
53
54 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
55 boost::fusion::unused_type T_move_copy BOOST_ATTRIBUTE_UNUSED = std::move(value);
56 boost::fusion::unused_type T_move_direct BOOST_ATTRIBUTE_UNUSED (std::move(value));
57 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
58 boost::fusion::unused_type T_move_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {std::move(value)};
59 boost::fusion::unused_type T_move_direct_brace BOOST_ATTRIBUTE_UNUSED {std::move(value)};
60 #endif
61 #endif
62 }
63
64 void unused_assignment()
65 {
66 boost::fusion::unused_type val1, val2;
67
68 val1 = val2;
69 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
70 val1 = {};
71 #endif
72 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
73 val1 = std::move(val2);
74 #endif
75
76
77 T value;
78
79 val1 = value;
80 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
81 val1 = std::move(value);
82 #endif
83 }
84
85 boost::type_traits::yes_type test_unused(boost::fusion::detail::unused_only const&);
86 boost::type_traits::no_type test_unused(...);
87
88 void only_unused()
89 {
90 BOOST_STATIC_ASSERT((sizeof(test_unused(boost::fusion::unused)) == sizeof(boost::type_traits::yes_type)));
91 BOOST_STATIC_ASSERT((sizeof(test_unused(0)) == sizeof(boost::type_traits::no_type)));
92
93 boost::fusion::unused_type my_unused;
94 (void)my_unused;
95 BOOST_STATIC_ASSERT((sizeof(test_unused(my_unused)) == sizeof(boost::type_traits::yes_type)));
96 }