File: mp_rename.cpp

package info (click to toggle)
boost1.90 1.90.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 593,120 kB
  • sloc: cpp: 4,190,908; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,774; makefile: 1,161; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (146 lines) | stat: -rw-r--r-- 7,365 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

//  Copyright 2015-2017 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt


#include <boost/core/lightweight_test_trait.hpp>
#include <boost/mp11/list.hpp>
#include <type_traits>
#include <tuple>
#include <utility>

template<class... T> struct X {};
template<class... T> using Y = X<T...>;

int main()
{
    using boost::mp11::mp_list;
    using boost::mp11::mp_rename;
    using boost::mp11::mp_apply;

    using L1 = mp_list<>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, mp_list>, mp_list<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, std::tuple>, std::tuple<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, X>, X<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, Y>, Y<>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L1>, mp_list<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L1>, std::tuple<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L1>, X<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L1>, Y<>>));

    using L2 = mp_list<char>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, mp_list>, mp_list<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, std::tuple>, std::tuple<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, X>, X<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, Y>, Y<char>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L2>, mp_list<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L2>, std::tuple<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L2>, X<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L2>, Y<char>>));

    using L3 = mp_list<char, double>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, mp_list>, mp_list<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, std::tuple>, std::tuple<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, X>, X<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, Y>, Y<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, std::pair>, std::pair<char, double>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L3>, mp_list<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L3>, std::tuple<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L3>, X<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L3>, Y<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L3>, std::pair<char, double>>));

    using L4 = mp_list<int, char, float>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, mp_list>, mp_list<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, std::tuple>, std::tuple<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, X>, X<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, Y>, Y<int, char, float>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L4>, mp_list<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L4>, std::tuple<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L4>, X<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L4>, Y<int, char, float>>));

    //

    using L5 = std::tuple<>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, mp_list>, mp_list<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, std::tuple>, std::tuple<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, X>, X<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, Y>, Y<>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L5>, mp_list<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L5>, std::tuple<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L5>, X<>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L5>, Y<>>));

    using L6 = std::tuple<char>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, mp_list>, mp_list<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, std::tuple>, std::tuple<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, X>, X<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, Y>, Y<char>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L6>, mp_list<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L6>, std::tuple<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L6>, X<char>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L6>, Y<char>>));

    using L7 = std::tuple<char, double>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, mp_list>, mp_list<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, std::tuple>, std::tuple<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, X>, X<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, Y>, Y<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, std::pair>, std::pair<char, double>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L7>, mp_list<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L7>, std::tuple<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L7>, X<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L7>, Y<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L7>, std::pair<char, double>>));

    using L8 = std::tuple<int, char, float>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, mp_list>, mp_list<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, std::tuple>, std::tuple<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, X>, X<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, Y>, Y<int, char, float>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L8>, mp_list<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L8>, std::tuple<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L8>, X<int, char, float>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L8>, Y<int, char, float>>));

    //

    using L9 = std::pair<char, double>;

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, mp_list>, mp_list<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, std::tuple>, std::tuple<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, X>, X<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, Y>, Y<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, std::pair>, std::pair<char, double>>));

    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L9>, mp_list<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L9>, std::tuple<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L9>, X<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L9>, Y<char, double>>));
    BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L9>, std::pair<char, double>>));

    //

    return boost::report_errors();
}