// Boost.TypeErasure library // // Copyright 2011 Steven Watanabe // // Distributed under the Boost Software License Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // $Id$ #if !defined(BOOST_PP_IS_ITERATING) #ifndef BOOST_TYPE_ERASURE_DETAIL_REBIND_PLACEHOLDERS_HPP_INCLUDED #define BOOST_TYPE_ERASURE_DETAIL_REBIND_PLACEHOLDERS_HPP_INCLUDED #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace type_erasure { template struct deduced; namespace detail { template struct rebind_placeholders { typedef void type; }; template struct identity { typedef T type; }; template struct vtable_adapter; #ifdef BOOST_TYPE_ERASURE_USE_MP11 template using rebind_placeholders_t = typename rebind_placeholders::type; template using rebind_one_placeholder = ::boost::mp11::mp_second< ::boost::mp11::mp_map_find >; template struct rebind_placeholders_in_argument_impl { template using apply = ::boost::type_erasure::detail::eval_if< ::boost::mp11::mp_map_contains::value, ::boost::type_erasure::detail::rebind_one_placeholder, ::boost::type_erasure::detail::first, T, Bindings >; }; template using rebind_placeholders_in_argument_t = typename ::boost::type_erasure::detail::rebind_placeholders_in_argument_impl::template apply; template using rebind_placeholders_in_argument = ::boost::mpl::identity< ::boost::type_erasure::detail::rebind_placeholders_in_argument_t >; template struct rebind_placeholders_in_argument_impl { template using apply = rebind_placeholders_in_argument_t&; }; template struct rebind_placeholders_in_argument_impl { template using apply = rebind_placeholders_in_argument_t&&; }; template struct rebind_placeholders_in_argument_impl { template using apply = rebind_placeholders_in_argument_t const; }; template using rebind_placeholders_in_deduced = typename ::boost::type_erasure::deduced< ::boost::type_erasure::detail::rebind_placeholders_t >::type; template using rebind_deduced_placeholder = ::boost::mp11::mp_second< ::boost::mp11::mp_map_find > >; template struct rebind_placeholders_in_argument_impl< ::boost::type_erasure::deduced > { template using apply = ::boost::type_erasure::detail::eval_if< ::boost::mp11::mp_map_contains >::value, ::boost::type_erasure::detail::rebind_deduced_placeholder, ::boost::type_erasure::detail::rebind_placeholders_in_deduced, F, Bindings >; }; template struct rebind_placeholders_in_argument_impl { template using apply = rebind_placeholders_in_argument_t (rebind_placeholders_in_argument_t...); }; template struct rebind_placeholders_in_argument_impl { template using apply = rebind_placeholders_in_argument_t (rebind_placeholders_in_argument_t::*) (rebind_placeholders_in_argument_t...); }; template struct rebind_placeholders_in_argument_impl { template using apply = rebind_placeholders_in_argument_t (rebind_placeholders_in_argument_t::*) (rebind_placeholders_in_argument_t...) const; }; template class T, class... U, class Bindings> struct rebind_placeholders, Bindings> { typedef ::boost::type_erasure::detail::make_mp_list xBindings; typedef T...> type; }; template struct rebind_placeholders, Bindings> { typedef ::boost::type_erasure::detail::make_mp_list xBindings; typedef vtable_adapter< rebind_placeholders_t, rebind_placeholders_in_argument_t > type; }; #else template struct rebind_placeholders_in_argument { BOOST_MPL_ASSERT((boost::mpl::or_< ::boost::mpl::not_< ::boost::type_erasure::is_placeholder >, ::boost::mpl::has_key >)); typedef typename ::boost::mpl::eval_if< ::boost::type_erasure::is_placeholder, ::boost::mpl::at, ::boost::type_erasure::detail::identity >::type type; }; template struct rebind_placeholders, Bindings> { typedef vtable_adapter< typename rebind_placeholders::type, typename rebind_placeholders_in_argument::type > type; }; template struct rebind_placeholders_in_argument { typedef typename ::boost::type_erasure::detail::rebind_placeholders_in_argument< T, Bindings >::type& type; }; #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template struct rebind_placeholders_in_argument { typedef typename ::boost::type_erasure::detail::rebind_placeholders_in_argument< T, Bindings >::type&& type; }; #endif template struct rebind_placeholders_in_argument { typedef const typename ::boost::type_erasure::detail::rebind_placeholders_in_argument< T, Bindings >::type type; }; template struct rebind_placeholders_in_deduced { typedef typename ::boost::type_erasure::deduced< typename ::boost::type_erasure::detail::rebind_placeholders::type >::type type; }; template struct rebind_placeholders_in_argument< ::boost::type_erasure::deduced, Bindings > { typedef typename ::boost::mpl::eval_if< ::boost::mpl::has_key >, ::boost::mpl::at >, ::boost::type_erasure::detail::rebind_placeholders_in_deduced< F, Bindings > >::type type; }; #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template class T, class... U, class Bindings> struct rebind_placeholders, Bindings> { typedef T::type...> type; }; template struct rebind_placeholders_in_argument { typedef typename ::boost::type_erasure::detail::rebind_placeholders_in_argument< R, Bindings >::type type(typename rebind_placeholders_in_argument::type...); }; template struct rebind_placeholders_in_argument { typedef typename ::boost::type_erasure::detail::rebind_placeholders_in_argument< R, Bindings >::type (rebind_placeholders_in_argument::type::*type) (typename rebind_placeholders_in_argument::type...); }; template struct rebind_placeholders_in_argument { typedef typename ::boost::type_erasure::detail::rebind_placeholders_in_argument< R, Bindings >::type (rebind_placeholders_in_argument::type::*type) (typename rebind_placeholders_in_argument::type...) const; }; #else #define BOOST_PP_FILENAME_1 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_ARITY) #include BOOST_PP_ITERATE() #endif #endif } } } #endif #else #define N BOOST_PP_ITERATION() #define BOOST_TYPE_ERASURE_REBIND(z, n, data) \ typename rebind_placeholders_in_argument::type #if N != 0 template class T, BOOST_PP_ENUM_PARAMS(N, class T), class Bindings> struct rebind_placeholders, Bindings> { typedef T type; }; #endif template struct rebind_placeholders_in_argument { typedef typename ::boost::type_erasure::detail::rebind_placeholders_in_argument< R, Bindings >::type type(BOOST_PP_ENUM(N, BOOST_TYPE_ERASURE_REBIND, T)); }; #undef BOOST_TYPE_ERASURE_REBIND #undef N #endif