]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mp11/test/tuple_for_each_cx.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / mp11 / test / tuple_for_each_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 14#include <boost/mp11/tuple.hpp>
92f5a8d4 15#include <boost/mp11/detail/config.hpp>
b32b8144
FG
16
17// Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++
18
20effc67 19#if defined( BOOST_MP11_NO_CONSTEXPR ) || ( !defined(_MSC_VER) && !defined( __GLIBCXX__ ) && __cplusplus < 201400L )
b32b8144
FG
20
21int main() {}
22
23#else
24
25#include <tuple>
26#include <type_traits>
27
28struct assert_is_integral
29{
30 template<class T> constexpr bool operator()( T ) const
31 {
32 static_assert( std::is_integral<T>::value, "T must be an integral type" );
33 return true;
34 }
35};
36
37int main()
38{
39 {
40 constexpr std::tuple<int, short, char> tp{ 1, 2, 3 };
41 constexpr auto r = boost::mp11::tuple_for_each( tp, assert_is_integral() );
42 (void)r;
43 }
44
45#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9
46// "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor"
47#else
48
49 {
50 constexpr std::tuple<> tp;
51 constexpr auto r = boost::mp11::tuple_for_each( tp, 11 );
52 static_assert( r == 11, "r == 11" );
53 }
54
55#endif
56}
57
58#endif