]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/tuple_apply_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 )
29 constexpr int f( int x
, int y
, int z
)
31 return x
* 100 + y
* 10 + z
;
34 constexpr int g( int x
, int y
)
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" );
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" );
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" );
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"
69 constexpr std::tuple
<> tp
;
70 constexpr auto r
= boost::mp11::tuple_apply( h
, tp
);
71 static_assert( r
== 11, "r == 11" );