summaryrefslogtreecommitdiff
path: root/boost/type_erasure/detail/instantiate.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/type_erasure/detail/instantiate.hpp')
-rw-r--r--boost/type_erasure/detail/instantiate.hpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/boost/type_erasure/detail/instantiate.hpp b/boost/type_erasure/detail/instantiate.hpp
index 74f3d27f83..742aa02a9b 100644
--- a/boost/type_erasure/detail/instantiate.hpp
+++ b/boost/type_erasure/detail/instantiate.hpp
@@ -28,6 +28,62 @@ namespace boost {
namespace type_erasure {
namespace detail {
+#ifdef BOOST_TYPE_ERASURE_USE_MP11
+
+template<class L>
+struct make_instantiate_concept_impl;
+
+template<class T, T t>
+struct instantiate_concept;
+
+template<class T>
+using instantiate_concept_impl = instantiate_concept<decltype(&T::apply), &T::apply>;
+
+template<class... T>
+struct make_instantiate_concept_impl< ::boost::mp11::mp_list<T...> >
+{
+ template<template<class> class F>
+ using apply = void(F<T>...);
+};
+
+template<class Map>
+struct instantiate_concept_rebind_f
+{
+ template<class T>
+ using apply =
+ typename ::boost::type_erasure::detail::rebind_placeholders<
+ T,
+ Map
+ >::type;
+};
+
+template<class Concept, class Map>
+using make_instantiate_concept =
+ ::boost::type_erasure::detail::make_instantiate_concept_impl<
+ ::boost::mp11::mp_transform<
+ ::boost::type_erasure::detail::instantiate_concept_rebind_f<
+ typename ::boost::type_erasure::detail::add_deductions<
+ ::boost::type_erasure::detail::make_mp_list<Map>,
+ typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
+ Concept
+ >::type
+ >::type
+ >::template apply,
+ ::boost::type_erasure::detail::normalize_concept_t<Concept>
+ >
+ >;
+
+#define BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map) \
+ ((void)(typename ::boost::type_erasure::detail::make_instantiate_concept<Concept, Map> \
+ ::template apply< ::boost::type_erasure::detail::instantiate_concept_impl>*)0)
+
+#define BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, P0, T0) \
+ ((void)(typename ::boost::type_erasure::detail::make_instantiate_concept< \
+ Concept, ::boost::mpl::map1< ::boost::mpl::pair<P0, T0> > > \
+ ::template apply< ::boost::type_erasure::detail::instantiate_concept_impl>*)0)
+
+#else
+
template<int N>
struct make_instantiate_concept_impl;
@@ -56,6 +112,8 @@ struct make_instantiate_concept {
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_FUNCTIONS)
#include BOOST_PP_ITERATE()
+#endif
+
}
}
}
@@ -72,6 +130,7 @@ struct make_instantiate_concept {
struct BOOST_PP_CAT(instantiate_concept, N) {
template<class Concept, class Map>
static void apply(Concept *, Map *) {
+#if N > 0
typedef typename ::boost::type_erasure::detail::normalize_concept<
Concept>::type normalized;
typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
@@ -88,6 +147,7 @@ struct BOOST_PP_CAT(instantiate_concept, N) {
>::type
>
>::type concept_sequence;
+#endif
BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_INSTANTIATE_IMPL, concept_sequence)
}
};