1 // Boost.TypeErasure library
3 // Copyright 2011 Steven Watanabe
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)
11 #if !defined(BOOST_PP_IS_ITERATING)
13 #ifndef BOOST_TYPE_ERASURE_DETAIL_GET_PLACEHOLDERS_HPP_INCLUDED
14 #define BOOST_TYPE_ERASURE_DETAIL_GET_PLACEHOLDERS_HPP_INCLUDED
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>
29 namespace type_erasure {
32 #ifdef BOOST_TYPE_ERASURE_USE_MP11
35 struct get_placeholders_in_argument_impl
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,
47 struct get_placeholders_in_argument_impl<T&>
50 using apply = typename ::boost::type_erasure::detail::get_placeholders_in_argument_impl<T>::template apply<Out>;
54 struct get_placeholders_in_argument_impl<T&&>
57 using apply = typename ::boost::type_erasure::detail::get_placeholders_in_argument_impl<T>::template apply<Out>;
61 struct get_placeholders_in_argument_impl<const T>
64 using apply = typename ::boost::type_erasure::detail::get_placeholders_in_argument_impl<T>::template apply<Out>;
67 template<class Out, class T>
68 using get_placeholders_f = typename get_placeholders_in_argument_impl<T>::template apply<Out>;
70 template<class Out, class... T>
71 using get_placeholders_impl =
72 ::boost::mp11::mp_fold<
73 ::boost::mp11::mp_list<T...>,
75 ::boost::type_erasure::detail::get_placeholders_f
78 template<class R, class... T>
79 struct get_placeholders_in_argument_impl<R(T...)>
82 using apply = ::boost::type_erasure::detail::get_placeholders_impl<Out, R, T...>;
85 template<class R, class C, class... T>
86 struct get_placeholders_in_argument_impl<R (C::*)(T...)>
89 using apply = ::boost::type_erasure::detail::get_placeholders_impl<Out, R, C, T...>;
92 template<class R, class C, class... T>
93 struct get_placeholders_in_argument_impl<R (C::*)(T...) const>
96 using apply = ::boost::type_erasure::detail::get_placeholders_impl<Out, R, C, T...>;
99 template<class T, class Out>
100 struct get_placeholders;
102 template<template<class...> class F, class... T, class Out>
103 struct get_placeholders<F<T...>, Out>
105 using type = ::boost::type_erasure::detail::get_placeholders_impl<Out, T...>;
108 template<class T, class Out>
109 using get_placeholders_t = typename ::boost::type_erasure::detail::get_placeholders<T, Out>::type;
113 template<class T, class Out>
114 struct get_placeholders_in_argument
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>
123 template<class T, class Out>
124 struct get_placeholders;
126 template<class T, class Out>
127 struct get_placeholders_in_argument<T&, Out>
129 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
135 template<class T, class Out>
136 struct get_placeholders_in_argument<const T, Out>
138 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
144 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
146 template<class Out, class... T>
147 struct get_placeholders_impl;
149 template<class Out, class T0, class... T>
150 struct get_placeholders_impl<Out, T0, T...>
152 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
154 typename get_placeholders_impl<Out, T...>::type
159 struct get_placeholders_impl<Out>
164 template<template<class...> class T, class... U, class Out>
165 struct get_placeholders<T<U...>, Out>
167 typedef typename get_placeholders_impl<Out, U...>::type type;
170 template<class R, class... T, class Out>
171 struct get_placeholders_in_argument<R(T...), Out>
173 typedef typename get_placeholders_impl<Out, R, T...>::type type;
176 template<class R, class C, class... T, class Out>
177 struct get_placeholders_in_argument<R (C::*)(T...), Out>
179 typedef typename get_placeholders_impl<Out, R, C, T...>::type type;
182 template<class R, class C, class... T, class Out>
183 struct get_placeholders_in_argument<R (C::*)(T...) const, Out>
185 typedef typename get_placeholders_impl<Out, R, C, T...>::type type;
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()
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));
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>
219 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_GET_PLACEHOLDER, T)
220 typedef BOOST_PP_CAT(type, N) type;
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>
229 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
233 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_GET_PLACEHOLDER, T)
234 typedef BOOST_PP_CAT(type, N) type;
237 #undef BOOST_TYPE_ERASURE_GET_PLACEHOLDER