]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mp11/test/tuple_apply_cx.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / mp11 / test / tuple_apply_cx.cpp
CommitLineData
b32b8144 1
11fdf7f2 2// Copyright 2015 Peter Dimov.
b32b8144
FG
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
11fdf7f2
TL
9
10#if defined(_MSC_VER)
11#pragma warning( disable: 4244 ) // 'initializing': conversion from 'int' to 'char', possible loss of data
12#endif
13
b32b8144
FG
14#include <boost/mp11/tuple.hpp>
15#include <boost/config.hpp>
16
17// Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++
18
11fdf7f2 19#if defined( BOOST_NO_CXX11_CONSTEXPR ) || ( !defined( __GLIBCXX__ ) && __cplusplus < 201400L )
b32b8144
FG
20
21int main() {}
22
23#else
24
25#include <tuple>
26#include <array>
27#include <utility>
28
29constexpr int f( int x, int y, int z )
30{
31 return x * 100 + y * 10 + z;
32}
33
34constexpr int g( int x, int y )
35{
36 return x * 10 + y;
37}
38
39constexpr int h()
40{
41 return 11;
42}
43
44int main()
45{
46 {
47 constexpr std::tuple<int, short, char> tp{ 1, 2, 3 };
48 constexpr auto r = boost::mp11::tuple_apply( f, tp );
49 static_assert( r == 123, "r == 123" );
50 }
51
52 {
53 constexpr std::pair<short, char> tp{ 1, 2 };
54 constexpr auto r = boost::mp11::tuple_apply( g, tp );
55 static_assert( r == 12, "r == 12" );
56 }
57
58 {
59 constexpr std::array<short, 3> tp{{ 1, 2, 3 }};
60 constexpr auto r = boost::mp11::tuple_apply( f, tp );
61 static_assert( r == 123, "r == 123" );
62 }
63
64#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9
65// "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor"
66#else
67
68 {
69 constexpr std::tuple<> tp;
70 constexpr auto r = boost::mp11::tuple_apply( h, tp );
71 static_assert( r == 11, "r == 11" );
72 }
73
74#endif
75}
76
77#endif