1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/variant/detail/substitute.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,231 @@
1.4 +
1.5 +#if !defined(BOOST_PP_IS_ITERATING)
1.6 +
1.7 +///// header body
1.8 +
1.9 +//-----------------------------------------------------------------------------
1.10 +// boost variant/detail/substitute.hpp header file
1.11 +// See http://www.boost.org for updates, documentation, and revision history.
1.12 +//-----------------------------------------------------------------------------
1.13 +//
1.14 +// Copyright (c) 2003
1.15 +// Eric Friedman
1.16 +//
1.17 +// Distributed under the Boost Software License, Version 1.0. (See
1.18 +// accompanying file LICENSE_1_0.txt or copy at
1.19 +// http://www.boost.org/LICENSE_1_0.txt)
1.20 +
1.21 +#ifndef BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
1.22 +#define BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
1.23 +
1.24 +#include "boost/mpl/aux_/config/ctps.hpp"
1.25 +
1.26 +#include "boost/variant/detail/substitute_fwd.hpp"
1.27 +#include "boost/mpl/aux_/lambda_arity_param.hpp"
1.28 +#include "boost/mpl/aux_/preprocessor/params.hpp"
1.29 +#include "boost/mpl/aux_/preprocessor/repeat.hpp"
1.30 +#include "boost/mpl/int_fwd.hpp"
1.31 +#include "boost/mpl/limits/arity.hpp"
1.32 +#include "boost/preprocessor/cat.hpp"
1.33 +#include "boost/preprocessor/empty.hpp"
1.34 +#include "boost/preprocessor/arithmetic/inc.hpp"
1.35 +#include "boost/preprocessor/iterate.hpp"
1.36 +
1.37 +namespace boost {
1.38 +namespace detail { namespace variant {
1.39 +
1.40 +#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
1.41 +
1.42 +///////////////////////////////////////////////////////////////////////////////
1.43 +// (detail) metafunction substitute
1.44 +//
1.45 +// Substitutes one type for another in the given type expression.
1.46 +//
1.47 +
1.48 +//
1.49 +// primary template
1.50 +//
1.51 +template <
1.52 + typename T, typename Dest, typename Source
1.53 + BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(
1.54 + typename Arity /* = ... (see substitute_fwd.hpp) */
1.55 + )
1.56 + >
1.57 +struct substitute
1.58 +{
1.59 + typedef T type;
1.60 +};
1.61 +
1.62 +//
1.63 +// tag substitution specializations
1.64 +//
1.65 +
1.66 +#define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(CV_) \
1.67 + template <typename Dest, typename Source> \
1.68 + struct substitute< \
1.69 + CV_ Source \
1.70 + , Dest \
1.71 + , Source \
1.72 + BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) \
1.73 + > \
1.74 + { \
1.75 + typedef CV_ Dest type; \
1.76 + }; \
1.77 + /**/
1.78 +
1.79 +BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG( BOOST_PP_EMPTY() )
1.80 +BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(const)
1.81 +BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(volatile)
1.82 +BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(const volatile)
1.83 +
1.84 +#undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG
1.85 +
1.86 +//
1.87 +// pointer specializations
1.88 +//
1.89 +#define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(CV_) \
1.90 + template <typename T, typename Dest, typename Source> \
1.91 + struct substitute< \
1.92 + T * CV_ \
1.93 + , Dest \
1.94 + , Source \
1.95 + BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) \
1.96 + > \
1.97 + { \
1.98 + typedef typename substitute< \
1.99 + T, Dest, Source \
1.100 + >::type * CV_ type; \
1.101 + }; \
1.102 + /**/
1.103 +
1.104 +BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER( BOOST_PP_EMPTY() )
1.105 +BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(const)
1.106 +BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(volatile)
1.107 +BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(const volatile)
1.108 +
1.109 +#undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER
1.110 +
1.111 +//
1.112 +// reference specializations
1.113 +//
1.114 +template <typename T, typename Dest, typename Source>
1.115 +struct substitute<
1.116 + T&
1.117 + , Dest
1.118 + , Source
1.119 + BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
1.120 + >
1.121 +{
1.122 + typedef typename substitute<
1.123 + T, Dest, Source
1.124 + >::type & type;
1.125 +};
1.126 +
1.127 +//
1.128 +// template expression (i.e., F<...>) specializations
1.129 +//
1.130 +
1.131 +#define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL(N) \
1.132 + typedef typename substitute< \
1.133 + BOOST_PP_CAT(U,N), Dest, Source \
1.134 + >::type BOOST_PP_CAT(u,N); \
1.135 + /**/
1.136 +
1.137 +#define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF(z, N, _) \
1.138 + BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL( BOOST_PP_INC(N) ) \
1.139 + /**/
1.140 +
1.141 +#define BOOST_PP_ITERATION_LIMITS (0,BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
1.142 +#define BOOST_PP_FILENAME_1 "boost/variant/detail/substitute.hpp"
1.143 +#include BOOST_PP_ITERATE()
1.144 +
1.145 +#undef BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL
1.146 +#undef BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF
1.147 +
1.148 +#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
1.149 +
1.150 +}} // namespace detail::variant
1.151 +} // namespace boost
1.152 +
1.153 +#endif // BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
1.154 +
1.155 +///// iteration, depth == 1
1.156 +
1.157 +#elif BOOST_PP_ITERATION_DEPTH() == 1
1.158 +#define i BOOST_PP_FRAME_ITERATION(1)
1.159 +
1.160 +#if i > 0
1.161 +
1.162 +//
1.163 +// template specializations
1.164 +//
1.165 +template <
1.166 + template < BOOST_MPL_PP_PARAMS(i,typename P) > class T
1.167 + , BOOST_MPL_PP_PARAMS(i,typename U)
1.168 + , typename Dest
1.169 + , typename Source
1.170 + >
1.171 +struct substitute<
1.172 + T< BOOST_MPL_PP_PARAMS(i,U) >
1.173 + , Dest
1.174 + , Source
1.175 + BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<( i )>)
1.176 + >
1.177 +{
1.178 +private:
1.179 + BOOST_MPL_PP_REPEAT(i, BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF, _)
1.180 +
1.181 +public:
1.182 + typedef T< BOOST_MPL_PP_PARAMS(i,u) > type;
1.183 +};
1.184 +
1.185 +//
1.186 +// function specializations
1.187 +//
1.188 +template <
1.189 + typename R
1.190 + , BOOST_MPL_PP_PARAMS(i,typename U)
1.191 + , typename Dest
1.192 + , typename Source
1.193 + >
1.194 +struct substitute<
1.195 + R (*)( BOOST_MPL_PP_PARAMS(i,U) )
1.196 + , Dest
1.197 + , Source
1.198 + BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
1.199 + >
1.200 +{
1.201 +private:
1.202 + typedef typename substitute< R, Dest, Source >::type r;
1.203 + BOOST_MPL_PP_REPEAT(i, BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF, _)
1.204 +
1.205 +public:
1.206 + typedef r (*type)( BOOST_MPL_PP_PARAMS(i,u) );
1.207 +};
1.208 +
1.209 +#elif i == 0
1.210 +
1.211 +//
1.212 +// zero-arg function specialization
1.213 +//
1.214 +template <
1.215 + typename R, typename Dest, typename Source
1.216 + >
1.217 +struct substitute<
1.218 + R (*)( void )
1.219 + , Dest
1.220 + , Source
1.221 + BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
1.222 + >
1.223 +{
1.224 +private:
1.225 + typedef typename substitute< R, Dest, Source >::type r;
1.226 +
1.227 +public:
1.228 + typedef r (*type)( void );
1.229 +};
1.230 +
1.231 +#endif // i
1.232 +
1.233 +#undef i
1.234 +#endif // BOOST_PP_IS_ITERATING