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/config.hpp>
25 #include <boost/type_erasure/is_placeholder.hpp>
28 namespace type_erasure {
31 template<class T, class Out>
32 struct get_placeholders_in_argument
34 typedef typename ::boost::mpl::eval_if<
35 ::boost::type_erasure::is_placeholder<T>,
36 ::boost::mpl::insert<Out, T>,
37 ::boost::mpl::identity<Out>
41 template<class T, class Out>
42 struct get_placeholders;
44 template<class T, class Out>
45 struct get_placeholders_in_argument<T&, Out>
47 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
53 template<class T, class Out>
54 struct get_placeholders_in_argument<const T, Out>
56 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
62 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
64 template<class Out, class... T>
65 struct get_placeholders_impl;
67 template<class Out, class T0, class... T>
68 struct get_placeholders_impl<Out, T0, T...>
70 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
72 typename get_placeholders_impl<Out, T...>::type
77 struct get_placeholders_impl<Out>
82 template<template<class...> class T, class... U, class Out>
83 struct get_placeholders<T<U...>, Out>
85 typedef typename get_placeholders_impl<Out, U...>::type type;
88 template<class R, class... T, class Out>
89 struct get_placeholders_in_argument<R(T...), Out>
91 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
95 typedef typename get_placeholders_impl<type0, T...>::type type;
100 #define BOOST_PP_FILENAME_1 <boost/type_erasure/detail/get_placeholders.hpp>
101 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_ARITY)
102 #include BOOST_PP_ITERATE()
114 #define N BOOST_PP_ITERATION()
115 #define BOOST_TYPE_ERASURE_GET_PLACEHOLDER(z, n, data) \
116 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument< \
117 BOOST_PP_CAT(data, n), BOOST_PP_CAT(type, n)>::type \
118 BOOST_PP_CAT(type, BOOST_PP_INC(n));
122 template<template<BOOST_PP_ENUM_PARAMS(N, class T)> class T,
123 BOOST_PP_ENUM_PARAMS(N, class T), class Out>
124 struct get_placeholders<T<BOOST_PP_ENUM_PARAMS(N, T)>, Out>
127 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_GET_PLACEHOLDER, T)
128 typedef BOOST_PP_CAT(type, N) type;
134 BOOST_PP_ENUM_TRAILING_PARAMS(N, class T), class Out>
135 struct get_placeholders_in_argument<R(BOOST_PP_ENUM_PARAMS(N, T)), Out>
137 typedef typename ::boost::type_erasure::detail::get_placeholders_in_argument<
141 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_GET_PLACEHOLDER, T)
142 typedef BOOST_PP_CAT(type, N) type;
145 #undef BOOST_TYPE_ERASURE_GET_PLACEHOLDER