]>
Commit | Line | Data |
---|---|---|
b32b8144 | 1 | |
11fdf7f2 | 2 | // Copyright 2015, 2017 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 | ||
9 | ||
11fdf7f2 TL |
10 | #if defined(_MSC_VER) |
11 | #pragma warning( disable: 4804 ) // '>=': unsafe use of type 'bool' in operation | |
12 | #endif | |
13 | ||
b32b8144 FG |
14 | #include <boost/mp11/algorithm.hpp> |
15 | #include <boost/mp11/list.hpp> | |
16 | #include <boost/mp11/integral.hpp> | |
17 | #include <boost/core/lightweight_test_trait.hpp> | |
18 | #include <type_traits> | |
19 | #include <tuple> | |
20 | #include <utility> | |
21 | ||
22 | struct X1 {}; | |
23 | struct X2 {}; | |
24 | struct X3 {}; | |
25 | struct X4 {}; | |
26 | struct X5 {}; | |
27 | ||
28 | int main() | |
29 | { | |
30 | using boost::mp11::mp_list; | |
31 | using boost::mp11::mp_replace_at; | |
32 | using boost::mp11::mp_int; | |
33 | using boost::mp11::mp_true; | |
34 | using boost::mp11::mp_false; | |
35 | ||
36 | { | |
37 | using L = mp_list<X1, X2, X3, X4, X5>; | |
38 | ||
39 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<0>, void>, mp_list<void, X2, X3, X4, X5>>)); | |
40 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<1>, void>, mp_list<X1, void, X3, X4, X5>>)); | |
41 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<2>, void>, mp_list<X1, X2, void, X4, X5>>)); | |
42 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<3>, void>, mp_list<X1, X2, X3, void, X5>>)); | |
43 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<4>, void>, mp_list<X1, X2, X3, X4, void>>)); | |
44 | } | |
45 | ||
46 | { | |
47 | using L = std::tuple<X1, X2, X3, X4, X5>; | |
48 | ||
49 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<0>, void>, std::tuple<void, X2, X3, X4, X5>>)); | |
50 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<1>, void>, std::tuple<X1, void, X3, X4, X5>>)); | |
51 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<2>, void>, std::tuple<X1, X2, void, X4, X5>>)); | |
52 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<3>, void>, std::tuple<X1, X2, X3, void, X5>>)); | |
53 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<4>, void>, std::tuple<X1, X2, X3, X4, void>>)); | |
54 | } | |
55 | ||
56 | { | |
57 | using L = std::pair<X1, X2>; | |
58 | ||
59 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_false, void>, std::pair<void, X2>>)); | |
60 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_true, void>, std::pair<X1, void>>)); | |
61 | } | |
62 | ||
63 | return boost::report_errors(); | |
64 | } |