]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/construct_from_tuple_cx.cpp
2 // Copyright 2015 Peter Dimov.
4 // 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
11 #pragma warning( disable: 4244 ) // 'initializing': conversion from 'int' to 'char', possible loss of data
14 #include <boost/mp11/tuple.hpp>
15 #include <boost/mp11/detail/config.hpp>
17 // Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++
19 #if defined( BOOST_MP11_NO_CONSTEXPR ) || ( !defined( __GLIBCXX__ ) && __cplusplus < 201400L )
33 constexpr T1( int x
= 0, int y
= 0, int z
= 0 ): x(x
), y(y
), z(z
) {}
38 using boost::mp11::construct_from_tuple
;
41 constexpr std::tuple
<int, short, char> tp
{ 1, 2, 3 };
43 constexpr auto r
= construct_from_tuple
<T1
>( tp
);
45 static_assert( r
.x
== 1, "r.x == 1" );
46 static_assert( r
.y
== 2, "r.y == 2" );
47 static_assert( r
.z
== 3, "r.z == 3" );
51 constexpr std::pair
<short, char> tp
{ 1, 2 };
53 constexpr auto r
= construct_from_tuple
<T1
>( tp
);
55 static_assert( r
.x
== 1, "r.x == 1" );
56 static_assert( r
.y
== 2, "r.y == 2" );
57 static_assert( r
.z
== 0, "r.z == 0" );
61 constexpr std::array
<short, 3> tp
{{ 1, 2, 3 }};
63 constexpr auto r
= construct_from_tuple
<T1
>( tp
);
65 static_assert( r
.x
== 1, "r.x == 1" );
66 static_assert( r
.y
== 2, "r.y == 2" );
67 static_assert( r
.z
== 3, "r.z == 3" );
70 #if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9
71 // "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor"
75 constexpr std::tuple
<> tp
;
77 constexpr auto r
= construct_from_tuple
<T1
>( tp
);
79 static_assert( r
.x
== 0, "r.x == 0" );
80 static_assert( r
.y
== 0, "r.y == 0" );
81 static_assert( r
.z
== 0, "r.z == 0" );