]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/tuple_apply_cx.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / mp11 / test / tuple_apply_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 constexpr int f( int x, int y, int z )
25 {
26 return x * 100 + y * 10 + z;
27 }
28
29 constexpr int g( int x, int y )
30 {
31 return x * 10 + y;
32 }
33
34 constexpr int h()
35 {
36 return 11;
37 }
38
39 int main()
40 {
41 {
42 constexpr std::tuple<int, short, char> tp{ 1, 2, 3 };
43 constexpr auto r = boost::mp11::tuple_apply( f, tp );
44 static_assert( r == 123, "r == 123" );
45 }
46
47 {
48 constexpr std::pair<short, char> tp{ 1, 2 };
49 constexpr auto r = boost::mp11::tuple_apply( g, tp );
50 static_assert( r == 12, "r == 12" );
51 }
52
53 {
54 constexpr std::array<short, 3> tp{{ 1, 2, 3 }};
55 constexpr auto r = boost::mp11::tuple_apply( f, tp );
56 static_assert( r == 123, "r == 123" );
57 }
58
59 #if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9
60 // "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor"
61 #else
62
63 {
64 constexpr std::tuple<> tp;
65 constexpr auto r = boost::mp11::tuple_apply( h, tp );
66 static_assert( r == 11, "r == 11" );
67 }
68
69 #endif
70 }
71
72 #endif