1 // Boost.TypeErasure library
3 // Copyright 2012 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_INSTANTIATE_HPP_INCLUDED
14 #define BOOST_TYPE_ERASURE_DETAIL_INSTANTIATE_HPP_INCLUDED
16 #include <boost/mpl/transform.hpp>
17 #include <boost/mpl/size.hpp>
18 #include <boost/mpl/at.hpp>
19 #include <boost/preprocessor/cat.hpp>
20 #include <boost/preprocessor/iteration/iterate.hpp>
21 #include <boost/preprocessor/repetition/repeat.hpp>
22 #include <boost/preprocessor/repetition/enum.hpp>
23 #include <boost/preprocessor/repetition/enum_params.hpp>
24 #include <boost/type_erasure/detail/normalize.hpp>
25 #include <boost/type_erasure/detail/rebind_placeholders.hpp>
28 namespace type_erasure {
32 struct make_instantiate_concept_impl;
34 template<class Concept>
35 struct make_instantiate_concept {
36 typedef typename ::boost::type_erasure::detail::normalize_concept<
37 Concept>::type normalized;
38 typedef typename ::boost::type_erasure::detail::make_instantiate_concept_impl<
39 (::boost::mpl::size<normalized>::value)
43 #define BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map) \
44 (::boost::type_erasure::detail::make_instantiate_concept< \
46 >::type::apply((Concept*)0, (Map*)0))
48 #define BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, P0, T0) \
49 (::boost::type_erasure::detail::make_instantiate_concept< \
53 (::boost::mpl::map1< ::boost::mpl::pair<P0, T0> >*)0))
55 #define BOOST_PP_FILENAME_1 <boost/type_erasure/detail/instantiate.hpp>
56 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_FUNCTIONS)
57 #include BOOST_PP_ITERATE()
67 #define N BOOST_PP_ITERATION()
69 #define BOOST_TYPE_ERASURE_INSTANTIATE_IMPL(z, n, data)\
70 (void)&::boost::mpl::at_c<data, n>::type::apply;
72 struct BOOST_PP_CAT(instantiate_concept, N) {
73 template<class Concept, class Map>
74 static void apply(Concept *, Map *) {
75 typedef typename ::boost::type_erasure::detail::normalize_concept<
76 Concept>::type normalized;
77 typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
79 >::type placeholder_subs;
81 typedef typename ::boost::mpl::transform<
83 ::boost::type_erasure::detail::rebind_placeholders<
85 typename ::boost::type_erasure::detail::add_deductions<
90 >::type concept_sequence;
91 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_INSTANTIATE_IMPL, concept_sequence)
96 struct make_instantiate_concept_impl<N>
98 typedef ::boost::type_erasure::detail::BOOST_PP_CAT(instantiate_concept, N) type;
101 #undef BOOST_TYPE_ERASURE_INSTANTIATE_IMPL