Chris@16
|
1 // Boost.TypeErasure library
|
Chris@16
|
2 //
|
Chris@16
|
3 // Copyright 2012 Steven Watanabe
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License Version 1.0. (See
|
Chris@16
|
6 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // $Id: instantiate.hpp 80881 2012-10-05 23:36:21Z steven_watanabe $
|
Chris@16
|
10
|
Chris@16
|
11 #if !defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
12
|
Chris@16
|
13 #ifndef BOOST_TYPE_ERASURE_DETAIL_INSTANTIATE_HPP_INCLUDED
|
Chris@16
|
14 #define BOOST_TYPE_ERASURE_DETAIL_INSTANTIATE_HPP_INCLUDED
|
Chris@16
|
15
|
Chris@16
|
16 #include <boost/mpl/transform.hpp>
|
Chris@16
|
17 #include <boost/mpl/size.hpp>
|
Chris@16
|
18 #include <boost/mpl/at.hpp>
|
Chris@16
|
19 #include <boost/preprocessor/cat.hpp>
|
Chris@16
|
20 #include <boost/preprocessor/iteration/iterate.hpp>
|
Chris@16
|
21 #include <boost/preprocessor/repetition/repeat.hpp>
|
Chris@16
|
22 #include <boost/preprocessor/repetition/enum.hpp>
|
Chris@16
|
23 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
24 #include <boost/type_erasure/detail/normalize.hpp>
|
Chris@16
|
25 #include <boost/type_erasure/detail/rebind_placeholders.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 namespace boost {
|
Chris@16
|
28 namespace type_erasure {
|
Chris@16
|
29 namespace detail {
|
Chris@16
|
30
|
Chris@16
|
31 template<int N>
|
Chris@16
|
32 struct make_instantiate_concept_impl;
|
Chris@16
|
33
|
Chris@16
|
34 template<class Concept>
|
Chris@16
|
35 struct make_instantiate_concept {
|
Chris@16
|
36 typedef typename ::boost::type_erasure::detail::normalize_concept<
|
Chris@16
|
37 Concept>::type normalized;
|
Chris@16
|
38 typedef typename ::boost::type_erasure::detail::make_instantiate_concept_impl<
|
Chris@16
|
39 (::boost::mpl::size<normalized>::value)
|
Chris@16
|
40 >::type type;
|
Chris@16
|
41 };
|
Chris@16
|
42
|
Chris@16
|
43 #define BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map) \
|
Chris@16
|
44 (::boost::type_erasure::detail::make_instantiate_concept< \
|
Chris@16
|
45 Concept \
|
Chris@16
|
46 >::type::apply((Concept*)0, (Map*)0))
|
Chris@16
|
47
|
Chris@16
|
48 #define BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, P0, T0) \
|
Chris@16
|
49 (::boost::type_erasure::detail::make_instantiate_concept< \
|
Chris@16
|
50 Concept \
|
Chris@16
|
51 >::type::apply( \
|
Chris@16
|
52 (Concept*)0, \
|
Chris@16
|
53 (::boost::mpl::map1< ::boost::mpl::pair<P0, T0> >*)0))
|
Chris@16
|
54
|
Chris@16
|
55 #define BOOST_PP_FILENAME_1 <boost/type_erasure/detail/instantiate.hpp>
|
Chris@16
|
56 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_FUNCTIONS)
|
Chris@16
|
57 #include BOOST_PP_ITERATE()
|
Chris@16
|
58
|
Chris@16
|
59 }
|
Chris@16
|
60 }
|
Chris@16
|
61 }
|
Chris@16
|
62
|
Chris@16
|
63 #endif
|
Chris@16
|
64
|
Chris@16
|
65 #else
|
Chris@16
|
66
|
Chris@16
|
67 #define N BOOST_PP_ITERATION()
|
Chris@16
|
68
|
Chris@16
|
69 #define BOOST_TYPE_ERASURE_INSTANTIATE_IMPL(z, n, data)\
|
Chris@16
|
70 (void)&::boost::mpl::at_c<data, n>::type::apply;
|
Chris@16
|
71
|
Chris@16
|
72 struct BOOST_PP_CAT(instantiate_concept, N) {
|
Chris@16
|
73 template<class Concept, class Map>
|
Chris@16
|
74 static void apply(Concept *, Map *) {
|
Chris@16
|
75 typedef typename ::boost::type_erasure::detail::normalize_concept<
|
Chris@16
|
76 Concept>::type normalized;
|
Chris@16
|
77 typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
|
Chris@16
|
78 Concept
|
Chris@16
|
79 >::type placeholder_subs;
|
Chris@16
|
80
|
Chris@16
|
81 typedef typename ::boost::mpl::transform<
|
Chris@16
|
82 normalized,
|
Chris@16
|
83 ::boost::type_erasure::detail::rebind_placeholders<
|
Chris@16
|
84 ::boost::mpl::_1,
|
Chris@16
|
85 typename ::boost::type_erasure::detail::add_deductions<
|
Chris@16
|
86 Map,
|
Chris@16
|
87 placeholder_subs
|
Chris@16
|
88 >::type
|
Chris@16
|
89 >
|
Chris@16
|
90 >::type concept_sequence;
|
Chris@16
|
91 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_INSTANTIATE_IMPL, concept_sequence)
|
Chris@16
|
92 }
|
Chris@16
|
93 };
|
Chris@16
|
94
|
Chris@16
|
95 template<>
|
Chris@16
|
96 struct make_instantiate_concept_impl<N>
|
Chris@16
|
97 {
|
Chris@16
|
98 typedef ::boost::type_erasure::detail::BOOST_PP_CAT(instantiate_concept, N) type;
|
Chris@16
|
99 };
|
Chris@16
|
100
|
Chris@16
|
101 #undef BOOST_TYPE_ERASURE_INSTANTIATE_IMPL
|
Chris@16
|
102
|
Chris@16
|
103 #undef N
|
Chris@16
|
104
|
Chris@16
|
105 #endif
|