sl@0: sl@0: #if !defined(BOOST_PP_IS_ITERATING) sl@0: sl@0: ///// header body sl@0: sl@0: //----------------------------------------------------------------------------- sl@0: // boost variant/detail/substitute.hpp header file sl@0: // See http://www.boost.org for updates, documentation, and revision history. sl@0: //----------------------------------------------------------------------------- sl@0: // sl@0: // Copyright (c) 2003 sl@0: // Eric Friedman sl@0: // sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: #ifndef BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP sl@0: #define BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP sl@0: sl@0: #include "boost/mpl/aux_/config/ctps.hpp" sl@0: sl@0: #include "boost/variant/detail/substitute_fwd.hpp" sl@0: #include "boost/mpl/aux_/lambda_arity_param.hpp" sl@0: #include "boost/mpl/aux_/preprocessor/params.hpp" sl@0: #include "boost/mpl/aux_/preprocessor/repeat.hpp" sl@0: #include "boost/mpl/int_fwd.hpp" sl@0: #include "boost/mpl/limits/arity.hpp" sl@0: #include "boost/preprocessor/cat.hpp" sl@0: #include "boost/preprocessor/empty.hpp" sl@0: #include "boost/preprocessor/arithmetic/inc.hpp" sl@0: #include "boost/preprocessor/iterate.hpp" sl@0: sl@0: namespace boost { sl@0: namespace detail { namespace variant { sl@0: sl@0: #if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE) sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // (detail) metafunction substitute sl@0: // sl@0: // Substitutes one type for another in the given type expression. sl@0: // sl@0: sl@0: // sl@0: // primary template sl@0: // sl@0: template < sl@0: typename T, typename Dest, typename Source sl@0: BOOST_MPL_AUX_LAMBDA_ARITY_PARAM( sl@0: typename Arity /* = ... (see substitute_fwd.hpp) */ sl@0: ) sl@0: > sl@0: struct substitute sl@0: { sl@0: typedef T type; sl@0: }; sl@0: sl@0: // sl@0: // tag substitution specializations sl@0: // sl@0: sl@0: #define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(CV_) \ sl@0: template \ sl@0: struct substitute< \ sl@0: CV_ Source \ sl@0: , Dest \ sl@0: , Source \ sl@0: BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) \ sl@0: > \ sl@0: { \ sl@0: typedef CV_ Dest type; \ sl@0: }; \ sl@0: /**/ sl@0: sl@0: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG( BOOST_PP_EMPTY() ) sl@0: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(const) sl@0: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(volatile) sl@0: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(const volatile) sl@0: sl@0: #undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG sl@0: sl@0: // sl@0: // pointer specializations sl@0: // sl@0: #define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(CV_) \ sl@0: template \ sl@0: struct substitute< \ sl@0: T * CV_ \ sl@0: , Dest \ sl@0: , Source \ sl@0: BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) \ sl@0: > \ sl@0: { \ sl@0: typedef typename substitute< \ sl@0: T, Dest, Source \ sl@0: >::type * CV_ type; \ sl@0: }; \ sl@0: /**/ sl@0: sl@0: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER( BOOST_PP_EMPTY() ) sl@0: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(const) sl@0: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(volatile) sl@0: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(const volatile) sl@0: sl@0: #undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER sl@0: sl@0: // sl@0: // reference specializations sl@0: // sl@0: template sl@0: struct substitute< sl@0: T& sl@0: , Dest sl@0: , Source sl@0: BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) sl@0: > sl@0: { sl@0: typedef typename substitute< sl@0: T, Dest, Source sl@0: >::type & type; sl@0: }; sl@0: sl@0: // sl@0: // template expression (i.e., F<...>) specializations sl@0: // sl@0: sl@0: #define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL(N) \ sl@0: typedef typename substitute< \ sl@0: BOOST_PP_CAT(U,N), Dest, Source \ sl@0: >::type BOOST_PP_CAT(u,N); \ sl@0: /**/ sl@0: sl@0: #define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF(z, N, _) \ sl@0: BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL( BOOST_PP_INC(N) ) \ sl@0: /**/ sl@0: sl@0: #define BOOST_PP_ITERATION_LIMITS (0,BOOST_MPL_LIMIT_METAFUNCTION_ARITY) sl@0: #define BOOST_PP_FILENAME_1 "boost/variant/detail/substitute.hpp" sl@0: #include BOOST_PP_ITERATE() sl@0: sl@0: #undef BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL sl@0: #undef BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF sl@0: sl@0: #endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE) sl@0: sl@0: }} // namespace detail::variant sl@0: } // namespace boost sl@0: sl@0: #endif // BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP sl@0: sl@0: ///// iteration, depth == 1 sl@0: sl@0: #elif BOOST_PP_ITERATION_DEPTH() == 1 sl@0: #define i BOOST_PP_FRAME_ITERATION(1) sl@0: sl@0: #if i > 0 sl@0: sl@0: // sl@0: // template specializations sl@0: // sl@0: template < sl@0: template < BOOST_MPL_PP_PARAMS(i,typename P) > class T sl@0: , BOOST_MPL_PP_PARAMS(i,typename U) sl@0: , typename Dest sl@0: , typename Source sl@0: > sl@0: struct substitute< sl@0: T< BOOST_MPL_PP_PARAMS(i,U) > sl@0: , Dest sl@0: , Source sl@0: BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<( i )>) sl@0: > sl@0: { sl@0: private: sl@0: BOOST_MPL_PP_REPEAT(i, BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF, _) sl@0: sl@0: public: sl@0: typedef T< BOOST_MPL_PP_PARAMS(i,u) > type; sl@0: }; sl@0: sl@0: // sl@0: // function specializations sl@0: // sl@0: template < sl@0: typename R sl@0: , BOOST_MPL_PP_PARAMS(i,typename U) sl@0: , typename Dest sl@0: , typename Source sl@0: > sl@0: struct substitute< sl@0: R (*)( BOOST_MPL_PP_PARAMS(i,U) ) sl@0: , Dest sl@0: , Source sl@0: BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) sl@0: > sl@0: { sl@0: private: sl@0: typedef typename substitute< R, Dest, Source >::type r; sl@0: BOOST_MPL_PP_REPEAT(i, BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF, _) sl@0: sl@0: public: sl@0: typedef r (*type)( BOOST_MPL_PP_PARAMS(i,u) ); sl@0: }; sl@0: sl@0: #elif i == 0 sl@0: sl@0: // sl@0: // zero-arg function specialization sl@0: // sl@0: template < sl@0: typename R, typename Dest, typename Source sl@0: > sl@0: struct substitute< sl@0: R (*)( void ) sl@0: , Dest sl@0: , Source sl@0: BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) sl@0: > sl@0: { sl@0: private: sl@0: typedef typename substitute< R, Dest, Source >::type r; sl@0: sl@0: public: sl@0: typedef r (*type)( void ); sl@0: }; sl@0: sl@0: #endif // i sl@0: sl@0: #undef i sl@0: #endif // BOOST_PP_IS_ITERATING