File indexing completed on 2025-12-16 10:10:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #if !defined(BOOST_PP_IS_ITERATING)
0012
0013 #ifndef BOOST_TYPE_ERASURE_DETAIL_INSTANTIATE_HPP_INCLUDED
0014 #define BOOST_TYPE_ERASURE_DETAIL_INSTANTIATE_HPP_INCLUDED
0015
0016 #include <boost/mpl/transform.hpp>
0017 #include <boost/mpl/size.hpp>
0018 #include <boost/mpl/at.hpp>
0019 #include <boost/preprocessor/cat.hpp>
0020 #include <boost/preprocessor/iteration/iterate.hpp>
0021 #include <boost/preprocessor/repetition/repeat.hpp>
0022 #include <boost/preprocessor/repetition/enum.hpp>
0023 #include <boost/preprocessor/repetition/enum_params.hpp>
0024 #include <boost/type_erasure/detail/normalize.hpp>
0025 #include <boost/type_erasure/detail/rebind_placeholders.hpp>
0026
0027 namespace boost {
0028 namespace type_erasure {
0029 namespace detail {
0030
0031 #ifdef BOOST_TYPE_ERASURE_USE_MP11
0032
0033 template<class L>
0034 struct make_instantiate_concept_impl;
0035
0036 template<class T, T t>
0037 struct instantiate_concept;
0038
0039 template<class T>
0040 using instantiate_concept_impl = instantiate_concept<decltype(&T::apply), &T::apply>;
0041
0042 template<class... T>
0043 struct make_instantiate_concept_impl< ::boost::mp11::mp_list<T...> >
0044 {
0045 template<template<class> class F>
0046 using apply = void(F<T>...);
0047 };
0048
0049 template<class Map>
0050 struct instantiate_concept_rebind_f
0051 {
0052 template<class T>
0053 using apply =
0054 typename ::boost::type_erasure::detail::rebind_placeholders<
0055 T,
0056 Map
0057 >::type;
0058 };
0059
0060 template<class Concept, class Map>
0061 using make_instantiate_concept =
0062 ::boost::type_erasure::detail::make_instantiate_concept_impl<
0063 ::boost::mp11::mp_transform<
0064 ::boost::type_erasure::detail::instantiate_concept_rebind_f<
0065 typename ::boost::type_erasure::detail::add_deductions<
0066 ::boost::type_erasure::detail::make_mp_list<Map>,
0067 typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
0068 Concept
0069 >::type
0070 >::type
0071 >::template apply,
0072 ::boost::type_erasure::detail::normalize_concept_t<Concept>
0073 >
0074 >;
0075
0076 #define BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map) \
0077 ((void)(typename ::boost::type_erasure::detail::make_instantiate_concept<Concept, Map> \
0078 ::template apply< ::boost::type_erasure::detail::instantiate_concept_impl>*)0)
0079
0080 #define BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, P0, T0) \
0081 ((void)(typename ::boost::type_erasure::detail::make_instantiate_concept< \
0082 Concept, ::boost::mpl::map1< ::boost::mpl::pair<P0, T0> > > \
0083 ::template apply< ::boost::type_erasure::detail::instantiate_concept_impl>*)0)
0084
0085 #else
0086
0087 template<int N>
0088 struct make_instantiate_concept_impl;
0089
0090 template<class Concept>
0091 struct make_instantiate_concept {
0092 typedef typename ::boost::type_erasure::detail::normalize_concept<
0093 Concept>::type normalized;
0094 typedef typename ::boost::type_erasure::detail::make_instantiate_concept_impl<
0095 (::boost::mpl::size<normalized>::value)
0096 >::type type;
0097 };
0098
0099 #define BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map) \
0100 (::boost::type_erasure::detail::make_instantiate_concept< \
0101 Concept \
0102 >::type::apply((Concept*)0, (Map*)0))
0103
0104 #define BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, P0, T0) \
0105 (::boost::type_erasure::detail::make_instantiate_concept< \
0106 Concept \
0107 >::type::apply( \
0108 (Concept*)0, \
0109 (::boost::mpl::map1< ::boost::mpl::pair<P0, T0> >*)0))
0110
0111 #define BOOST_PP_FILENAME_1 <boost/type_erasure/detail/instantiate.hpp>
0112 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_FUNCTIONS)
0113 #include BOOST_PP_ITERATE()
0114
0115 #endif
0116
0117 }
0118 }
0119 }
0120
0121 #endif
0122
0123 #else
0124
0125 #define N BOOST_PP_ITERATION()
0126
0127 #define BOOST_TYPE_ERASURE_INSTANTIATE_IMPL(z, n, data)\
0128 (void)&::boost::mpl::at_c<data, n>::type::apply;
0129
0130 struct BOOST_PP_CAT(instantiate_concept, N) {
0131 template<class Concept, class Map>
0132 static void apply(Concept *, Map *) {
0133 #if N > 0
0134 typedef typename ::boost::type_erasure::detail::normalize_concept<
0135 Concept>::type normalized;
0136 typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
0137 Concept
0138 >::type placeholder_subs;
0139
0140 typedef typename ::boost::mpl::transform<
0141 normalized,
0142 ::boost::type_erasure::detail::rebind_placeholders<
0143 ::boost::mpl::_1,
0144 typename ::boost::type_erasure::detail::add_deductions<
0145 Map,
0146 placeholder_subs
0147 >::type
0148 >
0149 >::type concept_sequence;
0150 #endif
0151 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_INSTANTIATE_IMPL, concept_sequence)
0152 }
0153 };
0154
0155 template<>
0156 struct make_instantiate_concept_impl<N>
0157 {
0158 typedef ::boost::type_erasure::detail::BOOST_PP_CAT(instantiate_concept, N) type;
0159 };
0160
0161 #undef BOOST_TYPE_ERASURE_INSTANTIATE_IMPL
0162
0163 #undef N
0164
0165 #endif