]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/construct_from_tuple_cx.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / mp11 / test / construct_from_tuple_cx.cpp
1
2 // Copyright 2015 Peter Dimov.
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 //
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
8
9 #include <boost/mp11/tuple.hpp>
10 #include <boost/config.hpp>
11
12 // Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++
13
14 #if defined( BOOST_NO_CXX11_CONSTEXPR ) || ( defined( _LIBCPP_VERSION ) && __cplusplus < 201400L )
15
16 int main() {}
17
18 #else
19
20 #include <tuple>
21 #include <array>
22 #include <utility>
23
24 struct T1
25 {
26 int x, y, z;
27
28 constexpr T1( int x = 0, int y = 0, int z = 0 ): x(x), y(y), z(z) {}
29 };
30
31 int main()
32 {
33 using boost::mp11::construct_from_tuple;
34
35 {
36 constexpr std::tuple<int, short, char> tp{ 1, 2, 3 };
37
38 constexpr auto r = construct_from_tuple<T1>( tp );
39
40 static_assert( r.x == 1, "r.x == 1" );
41 static_assert( r.y == 2, "r.y == 2" );
42 static_assert( r.z == 3, "r.z == 3" );
43 }
44
45 {
46 constexpr std::pair<short, char> tp{ 1, 2 };
47
48 constexpr auto r = construct_from_tuple<T1>( tp );
49
50 static_assert( r.x == 1, "r.x == 1" );
51 static_assert( r.y == 2, "r.y == 2" );
52 static_assert( r.z == 0, "r.z == 0" );
53 }
54
55 {
56 constexpr std::array<short, 3> tp{{ 1, 2, 3 }};
57
58 constexpr auto r = construct_from_tuple<T1>( tp );
59
60 static_assert( r.x == 1, "r.x == 1" );
61 static_assert( r.y == 2, "r.y == 2" );
62 static_assert( r.z == 3, "r.z == 3" );
63 }
64
65 #if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9
66 // "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor"
67 #else
68
69 {
70 constexpr std::tuple<> tp;
71
72 constexpr auto r = construct_from_tuple<T1>( tp );
73
74 static_assert( r.x == 0, "r.x == 0" );
75 static_assert( r.y == 0, "r.y == 0" );
76 static_assert( r.z == 0, "r.z == 0" );
77 }
78
79 #endif
80 }
81
82 #endif