]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | #ifndef BOOST_MP11_DETAIL_MPL_COMMON_HPP_INCLUDED |
2 | #define BOOST_MP11_DETAIL_MPL_COMMON_HPP_INCLUDED | |
3 | ||
4 | // Copyright 2017, 2019 Peter Dimov. | |
5 | // | |
6 | // Distributed under the Boost Software License, Version 1.0. | |
7 | // | |
8 | // See accompanying file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt | |
10 | ||
11 | #include <boost/mp11/list.hpp> | |
12 | #include <boost/mp11/algorithm.hpp> | |
13 | ||
14 | namespace boost | |
15 | { | |
16 | namespace mpl | |
17 | { | |
18 | ||
19 | struct forward_iterator_tag; | |
20 | ||
21 | namespace aux | |
22 | { | |
23 | ||
24 | struct mp11_tag {}; | |
25 | ||
26 | template<class L> struct mp11_iterator | |
27 | { | |
28 | using category = forward_iterator_tag; | |
29 | ||
30 | using type = mp11::mp_first<L>; | |
31 | using next = mp11_iterator<mp11::mp_rest<L>>; | |
32 | }; | |
33 | ||
34 | } // namespace aux | |
35 | ||
36 | // at | |
37 | ||
38 | template< typename Tag > struct at_impl; | |
39 | ||
40 | template<> struct at_impl<aux::mp11_tag> | |
41 | { | |
42 | template<class L, class I> struct apply | |
43 | { | |
44 | using type = mp11::mp_at<L, I>; | |
45 | }; | |
46 | }; | |
47 | ||
48 | // back | |
49 | ||
50 | template< typename Tag > struct back_impl; | |
51 | ||
52 | template<> struct back_impl<aux::mp11_tag> | |
53 | { | |
54 | template<class L> struct apply | |
55 | { | |
56 | using N = mp11::mp_size<L>; | |
57 | using type = mp11::mp_at_c<L, N::value - 1>; | |
58 | }; | |
59 | }; | |
60 | ||
61 | // begin | |
62 | ||
63 | template< typename Tag > struct begin_impl; | |
64 | ||
65 | template<> struct begin_impl<aux::mp11_tag> | |
66 | { | |
67 | template<class L> struct apply | |
68 | { | |
69 | using type = aux::mp11_iterator<L>; | |
70 | }; | |
71 | }; | |
72 | ||
73 | // clear | |
74 | ||
75 | template< typename Tag > struct clear_impl; | |
76 | ||
77 | template<> struct clear_impl<aux::mp11_tag> | |
78 | { | |
79 | template<class L> struct apply | |
80 | { | |
81 | using type = mp11::mp_clear<L>; | |
82 | }; | |
83 | }; | |
84 | ||
85 | // end | |
86 | ||
87 | template< typename Tag > struct end_impl; | |
88 | ||
89 | template<> struct end_impl<aux::mp11_tag> | |
90 | { | |
91 | template<class L> struct apply | |
92 | { | |
93 | using type = aux::mp11_iterator<mp11::mp_clear<L>>; | |
94 | }; | |
95 | }; | |
96 | ||
97 | // front | |
98 | ||
99 | template< typename Tag > struct front_impl; | |
100 | ||
101 | template<> struct front_impl<aux::mp11_tag> | |
102 | { | |
103 | template<class L> struct apply | |
104 | { | |
105 | using type = mp11::mp_front<L>; | |
106 | }; | |
107 | }; | |
108 | ||
109 | // pop_front | |
110 | ||
111 | template< typename Tag > struct pop_front_impl; | |
112 | ||
113 | template<> struct pop_front_impl<aux::mp11_tag> | |
114 | { | |
115 | template<class L> struct apply | |
116 | { | |
117 | using type = mp11::mp_pop_front<L>; | |
118 | }; | |
119 | }; | |
120 | ||
121 | // push_back | |
122 | ||
123 | template< typename Tag > struct push_back_impl; | |
124 | ||
125 | template<> struct push_back_impl<aux::mp11_tag> | |
126 | { | |
127 | template<class L, class T> struct apply | |
128 | { | |
129 | using type = mp11::mp_push_back<L, T>; | |
130 | }; | |
131 | }; | |
132 | ||
133 | // push_front | |
134 | ||
135 | template< typename Tag > struct push_front_impl; | |
136 | ||
137 | template<> struct push_front_impl<aux::mp11_tag> | |
138 | { | |
139 | template<class L, class T> struct apply | |
140 | { | |
141 | using type = mp11::mp_push_front<L, T>; | |
142 | }; | |
143 | }; | |
144 | ||
145 | // size | |
146 | ||
147 | template< typename Tag > struct size_impl; | |
148 | ||
149 | template<> struct size_impl<aux::mp11_tag> | |
150 | { | |
151 | template<class L> struct apply | |
152 | { | |
153 | using type = mp11::mp_size<L>; | |
154 | }; | |
155 | }; | |
156 | ||
157 | } // namespace mpl | |
158 | } // namespace boost | |
159 | ||
160 | #endif // #ifndef BOOST_MP11_DETAIL_MPL_COMMON_HPP_INCLUDED |