]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/move/test/type_traits.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / move / test / type_traits.cpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2015-2015.
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // See http://www.boost.org/libs/move for documentation.
10 //
11 //////////////////////////////////////////////////////////////////////////////
12 #include <boost/move/detail/type_traits.hpp>
13 #include <boost/move/core.hpp>
14 #include <boost/static_assert.hpp>
15 #include <boost/core/lightweight_test.hpp>
16
17 //
18 // pod_struct
19 //
20 #if defined(BOOST_MOVE_IS_POD)
21 struct pod_struct
22 {
23 int i;
24 float f;
25 };
26 #endif
27
28 //
29 // deleted_copy_and_assign_type
30 //
31 #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
32
33 struct deleted_copy_and_assign_type
34 {
35 deleted_copy_and_assign_type(const deleted_copy_and_assign_type&) = delete;
36 deleted_copy_and_assign_type & operator=(const deleted_copy_and_assign_type&) = delete;
37 };
38
39 #endif //defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
40
41 //
42 // boost_move_type
43 //
44 class boost_move_type
45 {
46 BOOST_MOVABLE_BUT_NOT_COPYABLE(boost_move_type)
47 public:
48 boost_move_type(BOOST_RV_REF(boost_move_type)){}
49 boost_move_type & operator=(BOOST_RV_REF(boost_move_type)){ return *this; }
50 };
51
52 namespace is_pod_test
53 {
54
55 void test()
56 {
57 BOOST_STATIC_ASSERT((boost::move_detail::is_pod<int>::value));
58 #if defined(BOOST_MOVE_IS_POD)
59 BOOST_STATIC_ASSERT((boost::move_detail::is_pod<pod_struct>::value));
60 #endif
61 }
62
63 } //namespace is_pod_test
64
65 namespace trivially_memcopyable_test {
66
67 void test()
68 {
69 #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
70 BOOST_STATIC_ASSERT(!(boost::move_detail::is_trivially_copy_constructible<deleted_copy_and_assign_type>::value));
71 BOOST_STATIC_ASSERT(!(boost::move_detail::is_trivially_copy_assignable<deleted_copy_and_assign_type>::value));
72 #endif //#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
73 //boost_move_type
74 BOOST_STATIC_ASSERT(!(boost::move_detail::is_trivially_copy_constructible<boost_move_type>::value));
75 BOOST_STATIC_ASSERT(!(boost::move_detail::is_trivially_copy_assignable<boost_move_type>::value));
76 BOOST_STATIC_ASSERT(!(boost::move_detail::is_copy_constructible<boost_move_type>::value));
77 BOOST_STATIC_ASSERT(!(boost::move_detail::is_copy_assignable<boost_move_type>::value));
78 //POD
79 BOOST_STATIC_ASSERT((boost::move_detail::is_trivially_copy_constructible<int>::value));
80 BOOST_STATIC_ASSERT((boost::move_detail::is_trivially_copy_assignable<int>::value));
81 BOOST_STATIC_ASSERT((boost::move_detail::is_copy_constructible<int>::value));
82 BOOST_STATIC_ASSERT((boost::move_detail::is_copy_assignable<int>::value));
83 #if defined(BOOST_MOVE_IS_POD)
84 BOOST_STATIC_ASSERT((boost::move_detail::is_trivially_copy_constructible<pod_struct>::value));
85 BOOST_STATIC_ASSERT((boost::move_detail::is_trivially_copy_assignable<pod_struct>::value));
86 BOOST_STATIC_ASSERT((boost::move_detail::is_copy_constructible<pod_struct>::value));
87 BOOST_STATIC_ASSERT((boost::move_detail::is_copy_assignable<pod_struct>::value));
88 #endif
89 }
90
91 } //namespace trivially_memcopyable_test {
92
93 int main()
94 {
95 trivially_memcopyable_test::test();
96 is_pod_test::test();
97 boost::report_errors();
98 }