Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:02:09

0001 //-----------------------------------------------------------------------------
0002 // boost variant/detail/substitute.hpp header file
0003 // See http://www.boost.org for updates, documentation, and revision history.
0004 //-----------------------------------------------------------------------------
0005 //
0006 // Copyright (c) 2003
0007 // Eric Friedman
0008 //
0009 // Distributed under the Boost Software License, Version 1.0. (See
0010 // accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 #ifndef BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
0014 #define BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
0015 
0016 #include <boost/mpl/aux_/config/ctps.hpp>
0017 
0018 #include <boost/variant/detail/substitute_fwd.hpp>
0019 #include <boost/variant/variant_fwd.hpp>
0020 #include <boost/mpl/aux_/lambda_arity_param.hpp>
0021 #include <boost/mpl/aux_/preprocessor/params.hpp>
0022 #include <boost/mpl/aux_/preprocessor/repeat.hpp>
0023 #include <boost/mpl/int_fwd.hpp>
0024 #include <boost/mpl/limits/arity.hpp>
0025 #include <boost/preprocessor/cat.hpp>
0026 #include <boost/preprocessor/empty.hpp>
0027 #include <boost/preprocessor/arithmetic/inc.hpp>
0028 #include <boost/preprocessor/iterate.hpp>
0029 
0030 namespace boost {
0031 namespace detail { namespace variant {
0032 
0033 ///////////////////////////////////////////////////////////////////////////////
0034 // (detail) metafunction substitute
0035 //
0036 // Substitutes one type for another in the given type expression.
0037 //
0038 
0039 //
0040 // primary template
0041 //
0042 template <
0043       typename T, typename Dest, typename Source
0044       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(
0045           typename Arity /* = ... (see substitute_fwd.hpp) */
0046         )
0047     >
0048 struct substitute
0049 {
0050     typedef T type;
0051 };
0052 
0053 //
0054 // tag substitution specializations
0055 //
0056 
0057 #define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(CV_) \
0058     template <typename Dest, typename Source> \
0059     struct substitute< \
0060           CV_ Source \
0061         , Dest \
0062         , Source \
0063           BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) \
0064         > \
0065     { \
0066         typedef CV_ Dest type; \
0067     }; \
0068     /**/
0069 
0070 BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG( BOOST_PP_EMPTY() )
0071 BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(const)
0072 BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(volatile)
0073 BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(const volatile)
0074 
0075 #undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG
0076 
0077 //
0078 // pointer specializations
0079 //
0080 #define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(CV_) \
0081     template <typename T, typename Dest, typename Source> \
0082     struct substitute< \
0083           T * CV_ \
0084         , Dest \
0085         , Source \
0086           BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) \
0087         > \
0088     { \
0089         typedef typename substitute< \
0090               T, Dest, Source \
0091             >::type * CV_ type; \
0092     }; \
0093     /**/
0094 
0095 BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER( BOOST_PP_EMPTY() )
0096 BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(const)
0097 BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(volatile)
0098 BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(const volatile)
0099 
0100 #undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER
0101 
0102 //
0103 // reference specializations
0104 //
0105 template <typename T, typename Dest, typename Source>
0106 struct substitute<
0107       T&
0108     , Dest
0109     , Source
0110       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
0111     >
0112 {
0113     typedef typename substitute<
0114           T, Dest, Source
0115         >::type & type;
0116 };
0117 
0118 //
0119 // template expression (i.e., F<...>) specializations
0120 //
0121 
0122 template <
0123       template <typename...> class F
0124     , typename... Ts
0125     , typename Dest
0126     , typename Source
0127       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
0128     >
0129 struct substitute<
0130       F<Ts...>
0131     , Dest
0132     , Source
0133       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
0134     >
0135 {
0136     typedef F<typename substitute<
0137           Ts, Dest, Source
0138         >::type...> type;
0139 };
0140 
0141 //
0142 // function specializations
0143 //
0144 template <
0145       typename R
0146     , typename... A
0147     , typename Dest
0148     , typename Source
0149     >
0150 struct substitute<
0151       R (*)(A...)
0152     , Dest
0153     , Source
0154       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
0155     >
0156 {
0157 private:
0158     typedef typename substitute< R, Dest, Source >::type r;
0159 
0160 public:
0161     typedef r (*type)(typename substitute<
0162           A, Dest, Source
0163         >::type...);
0164 };
0165 
0166 }} // namespace detail::variant
0167 } // namespace boost
0168 
0169 #endif // BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP