]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/type_erasure/detail/get_placeholders.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / type_erasure / detail / get_placeholders.hpp
1 // Boost.TypeErasure library
2 //
3 // Copyright 2011 Steven Watanabe
4 //
5 // Distributed under the Boost Software License Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // $Id$
10
11 #if !defined(BOOST_PP_IS_ITERATING)
12
13 #ifndef BOOST_TYPE_ERASURE_DETAIL_GET_PLACEHOLDERS_HPP_INCLUDED
14 #define BOOST_TYPE_ERASURE_DETAIL_GET_PLACEHOLDERS_HPP_INCLUDED
15
16 #include <boost/mpl/eval_if.hpp>
17 #include <boost/mpl/identity.hpp>
18 #include <boost/mpl/insert.hpp>
19 #include <boost/preprocessor/cat.hpp>
20 #include <boost/preprocessor/iteration/iterate.hpp>
21 #include <boost/preprocessor/repetition/enum.hpp>
22 #include <boost/preprocessor/repetition/enum_params.hpp>
23 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
24 #include <boost/type_erasure/detail/meta.hpp>
25 #include <boost/type_erasure/config.hpp>
26 #include <boost/type_erasure/is_placeholder.hpp>
27
28 namespace boost {
29 namespace type_erasure {
30 namespace detail {
31
32 #ifdef BOOST_TYPE_ERASURE_USE_MP11
33
34 template<class T>
35 struct get_placeholders_in_argument_impl
36 {
37 template<class Out>
38 using apply = ::boost::type_erasure::detail::eval_if<
39 ::boost::type_erasure::is_placeholder<T>::value,
40 ::boost::mp11::mp_set_push_back,
41 ::boost::type_erasure::detail::first,
42 Out, T
43 >;
44 };
45
46 template<class T>
47 struct get_placeholders_in_argument_impl<T&>
48 {
49 template<class Out>
50 using apply = typename ::boost::type_erasure::detail::get_placeholders_in_argument_impl<T>::template apply<Out>;
51 };
52
53 template<class T>
54 struct get_placeholders_in_argument_impl<T&&>
55 {
56 template<class Out>
57 using apply = typename ::boost::type_erasure::detail::get_placeholders_in_argument_impl<T>::template apply<Out>;
58 };
59
60 template<class T>
61 struct get_placeholders_in_argument_impl<const T>
62 {
63 template<class Out>
64 using apply = typename ::boost::type_erasure::detail::get_placeholders_in_argument_impl<T>::template apply<Out>;
65 };
66
67 template<class Out, class T>
68 using get_placeholders_f = typename get_placeholders_in_argument_impl<T>::template apply<Out>;
69
70 template<class Out, class... T>
71 using get_placeholders_impl =
72 ::boost::mp11::mp_fold<
73 ::boost::mp11::mp_list<T...>,
74 Out,
75 ::boost::type_erasure::detail::get_placeholders_f
76 >;
77
78 template<class R, class... T>
79 struct get_placeholders_in_argument_impl<R(T...)>
80 {
81 template<class Out>
82 using apply = ::boost::type_erasure::detail::get_placeholders_impl<Out, R, T...>;
83 };
84
85 template<class R, class C, class... T>
86 struct get_placeholders_in_argument_impl<R (C::*)(T...)>
87 {
88 template<class Out>
89 using apply = ::boost::type_erasure::detail::get_placeholders_impl<Out, R, C, T...>;
90 };
91
92 template<class R, class C, class... T>
93 struct get_placeholders_in_argument_impl<R (C::*)(T...) const>
94 {
95 template<class Out>
96 using apply = ::boost::type_erasure::detail::get_placeholders_impl<Out, R, C, T...>;
97 };
98
99 template<class T, class Out>
100 struct get_placeholders;
101
102 template<template<class...> class F, class... T, class Out>
103 struct get_placeholders<F<T...>, Out>
104 {
105 using type = ::boost::type_erasure::detail::get_placeholders_impl<Out, T...>;
106 };
107
108 template<class T, class Out>
109 using get_placeholders_t = typename ::boost::type_erasure::detail::get_placeholders<T, Out>::type;
110
111 #else
112
113 template<class T, class Out>
114 struct get_placeholders_in_argument
115 {
116 typedef typename ::boost::mpl::eval_if<
117 ::boost::type_erasure::is_placeholder<T>,
118 ::boost::mpl::insert<Out, T>,
119 ::boost::mpl::identity<Out>
120 >::type type;
121 };
122
123 template<class T, class Out>
124 struct get_placeholders;
125
126 template<class T, class Out>
127 struct get_placeholders_in_argument<T&, Out>
128 {
129 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
130 T,
131 Out
132 >::type type;
133 };
134
135 template<class T, class Out>
136 struct get_placeholders_in_argument<const T, Out>
137 {
138 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
139 T,
140 Out
141 >::type type;
142 };
143
144 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
145
146 template<class Out, class... T>
147 struct get_placeholders_impl;
148
149 template<class Out, class T0, class... T>
150 struct get_placeholders_impl<Out, T0, T...>
151 {
152 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
153 T0,
154 typename get_placeholders_impl<Out, T...>::type
155 >::type type;
156 };
157
158 template<class Out>
159 struct get_placeholders_impl<Out>
160 {
161 typedef Out type;
162 };
163
164 template<template<class...> class T, class... U, class Out>
165 struct get_placeholders<T<U...>, Out>
166 {
167 typedef typename get_placeholders_impl<Out, U...>::type type;
168 };
169
170 template<class R, class... T, class Out>
171 struct get_placeholders_in_argument<R(T...), Out>
172 {
173 typedef typename get_placeholders_impl<Out, R, T...>::type type;
174 };
175
176 template<class R, class C, class... T, class Out>
177 struct get_placeholders_in_argument<R (C::*)(T...), Out>
178 {
179 typedef typename get_placeholders_impl<Out, R, C, T...>::type type;
180 };
181
182 template<class R, class C, class... T, class Out>
183 struct get_placeholders_in_argument<R (C::*)(T...) const, Out>
184 {
185 typedef typename get_placeholders_impl<Out, R, C, T...>::type type;
186 };
187
188 #else
189
190 #define BOOST_PP_FILENAME_1 <boost/type_erasure/detail/get_placeholders.hpp>
191 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_ARITY)
192 #include BOOST_PP_ITERATE()
193
194 #endif
195
196 #endif
197
198 }
199 }
200 }
201
202 #endif
203
204 #else
205
206 #define N BOOST_PP_ITERATION()
207 #define BOOST_TYPE_ERASURE_GET_PLACEHOLDER(z, n, data) \
208 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument< \
209 BOOST_PP_CAT(data, n), BOOST_PP_CAT(type, n)>::type \
210 BOOST_PP_CAT(type, BOOST_PP_INC(n));
211
212 #if N != 0
213
214 template<template<BOOST_PP_ENUM_PARAMS(N, class T)> class T,
215 BOOST_PP_ENUM_PARAMS(N, class T), class Out>
216 struct get_placeholders<T<BOOST_PP_ENUM_PARAMS(N, T)>, Out>
217 {
218 typedef Out type0;
219 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_GET_PLACEHOLDER, T)
220 typedef BOOST_PP_CAT(type, N) type;
221 };
222
223 #endif
224
225 template<class R
226 BOOST_PP_ENUM_TRAILING_PARAMS(N, class T), class Out>
227 struct get_placeholders_in_argument<R(BOOST_PP_ENUM_PARAMS(N, T)), Out>
228 {
229 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
230 R,
231 Out
232 >::type type0;
233 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_GET_PLACEHOLDER, T)
234 typedef BOOST_PP_CAT(type, N) type;
235 };
236
237 #undef BOOST_TYPE_ERASURE_GET_PLACEHOLDER
238 #undef N
239
240 #endif