Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:43:27

0001 // Copyright Cromwell D. Enage 2018.
0002 // Distributed under the Boost Software License, Version 1.0.
0003 // (See accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_NO_SPEC_OVERLOADS_HPP
0007 #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_NO_SPEC_OVERLOADS_HPP
0008 
0009 #include <boost/parameter/aux_/preprocessor/impl/function_name.hpp>
0010 
0011 // Defines the no-spec implementation function header.
0012 #define BOOST_PARAMETER_NO_SPEC_FUNCTION_IMPL_HEAD(name, is_const)           \
0013     template <typename ResultType, typename Args>                            \
0014     BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) ResultType                  \
0015         BOOST_PARAMETER_NO_SPEC_FUNCTION_IMPL_NAME(                          \
0016             name, is_const                                                   \
0017         )(ResultType(*)(), Args const& args)
0018 /**/
0019 
0020 #include <boost/parameter/config.hpp>
0021 
0022 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
0023 
0024 #include <boost/parameter/aux_/preprocessor/impl/parenthesized_return_type.hpp>
0025 
0026 // Expands to the result metafunction for the specified no-spec function.
0027 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0028 #define BOOST_PARAMETER_NO_SPEC_FUNCTION_HEAD(result, name, is_const)        \
0029     template <typename TaggedArg0, typename ...TaggedArgs>                   \
0030     using BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(name, is_const)       \
0031     = typename BOOST_PARAMETER_PARENTHESIZED_RETURN_TYPE(result);
0032 /**/
0033 #else
0034 #define BOOST_PARAMETER_NO_SPEC_FUNCTION_HEAD(result, name, is_const)        \
0035     template <typename TaggedArg0, typename ...TaggedArgs>                   \
0036     struct BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(name, is_const)      \
0037       : BOOST_PARAMETER_PARENTHESIZED_RETURN_TYPE(result)                    \
0038     {                                                                        \
0039     };
0040 /**/
0041 #endif  // BOOST_PARAMETER_CAN_USE_MP11
0042 
0043 #include <boost/parameter/compose.hpp>
0044 #include <boost/parameter/are_tagged_arguments.hpp>
0045 #include <boost/parameter/aux_/preprocessor/impl/parenthesized_type.hpp>
0046 #include <boost/core/enable_if.hpp>
0047 
0048 // Exapnds to a variadic constructor that is enabled if and only if all its
0049 // arguments are tagged arguments.  The enclosing class must inherit from the
0050 // specified base class, which in turn must implement a constructor that takes
0051 // in the argument pack that this one passes on.
0052 #define BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(class_, base)                    \
0053     template <                                                               \
0054         typename TaggedArg0                                                  \
0055       , typename ...TaggedArgs                                               \
0056       , typename = typename ::boost::enable_if<                              \
0057             ::boost::parameter                                               \
0058             ::are_tagged_arguments<TaggedArg0,TaggedArgs...>                 \
0059         >::type                                                              \
0060     > inline explicit                                                        \
0061     class_(TaggedArg0 const& arg0, TaggedArgs const&... args)                \
0062       : BOOST_PARAMETER_PARENTHESIZED_TYPE(base)(                            \
0063             ::boost::parameter::compose(arg0, args...)                       \
0064         )                                                                    \
0065     {                                                                        \
0066     }
0067 /**/
0068 
0069 // Exapnds to a variadic constructor that is enabled if and only if all its
0070 // arguments are tagged arguments.  The specified function must be able to
0071 // take in the argument pack that this constructor passes on.
0072 #define BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(class_, func)            \
0073     template <                                                               \
0074         typename TaggedArg0                                                  \
0075       , typename ...TaggedArgs                                               \
0076       , typename = typename ::boost::enable_if<                              \
0077             ::boost::parameter                                               \
0078             ::are_tagged_arguments<TaggedArg0,TaggedArgs...>                 \
0079         >::type                                                              \
0080     > inline explicit                                                        \
0081     class_(TaggedArg0 const& arg0, TaggedArgs const&... args)                \
0082     {                                                                        \
0083         func(::boost::parameter::compose(arg0, args...));                    \
0084     }
0085 /**/
0086 
0087 #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
0088 #include <boost/preprocessor/control/expr_if.hpp>
0089 
0090 // Exapnds to a variadic function that is enabled if and only if
0091 // all its arguments are tagged arguments.
0092 #define BOOST_PARAMETER_NO_SPEC_FUNCTION_OVERLOAD(name, impl, is_m, c)       \
0093     template <typename TaggedArg0, typename ...TaggedArgs>                   \
0094     BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(impl)                             \
0095     inline typename ::boost::lazy_enable_if<                                 \
0096         ::boost::parameter                                                   \
0097         ::are_tagged_arguments<TaggedArg0,TaggedArgs...>                     \
0098       , BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(                        \
0099             impl, c                                                          \
0100         )<TaggedArg0,TaggedArgs...>                                          \
0101     >::type BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name)                       \
0102     (TaggedArg0 const& arg0, TaggedArgs const&... args)                      \
0103     BOOST_PP_EXPR_IF(c, const)                                               \
0104     {                                                                        \
0105         return BOOST_PP_EXPR_IF(is_m, this->)                                \
0106         BOOST_PARAMETER_NO_SPEC_FUNCTION_IMPL_NAME(impl, c)(                 \
0107             static_cast<                                                     \
0108                 typename BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(       \
0109                     impl, c                                                  \
0110                 )<TaggedArg0,TaggedArgs...>::type(*)()                       \
0111             >(BOOST_PARAMETER_AUX_PP_NULLPTR)                                \
0112           , ::boost::parameter::compose(arg0, args...)                       \
0113         );                                                                   \
0114     }
0115 /**/
0116 
0117 #else   // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
0118 
0119 #include <boost/parameter/aux_/void.hpp>
0120 #include <boost/parameter/aux_/preprocessor/impl/parenthesized_return_type.hpp>
0121 #include <boost/preprocessor/facilities/intercept.hpp>
0122 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
0123 
0124 // Expands to the result metafunction for the specified no-spec function.
0125 #define BOOST_PARAMETER_NO_SPEC_FUNCTION_HEAD(result, name, is_const)        \
0126     template <                                                               \
0127         BOOST_PP_ENUM_BINARY_PARAMS(                                         \
0128             BOOST_PARAMETER_COMPOSE_MAX_ARITY                                \
0129           , typename TaggedArg                                               \
0130           , = ::boost::parameter::void_ BOOST_PP_INTERCEPT                   \
0131         )                                                                    \
0132     >                                                                        \
0133     struct BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(name, is_const)      \
0134       : BOOST_PARAMETER_PARENTHESIZED_RETURN_TYPE(result)                    \
0135     {                                                                        \
0136     };
0137 /**/
0138 
0139 #include <boost/parameter/compose.hpp>
0140 #include <boost/parameter/aux_/preprocessor/impl/parenthesized_type.hpp>
0141 #include <boost/preprocessor/comparison/equal.hpp>
0142 #include <boost/preprocessor/control/expr_if.hpp>
0143 #include <boost/preprocessor/repetition/enum_params.hpp>
0144 #include <boost/preprocessor/tuple/elem.hpp>
0145 
0146 #if defined(BOOST_NO_SFINAE)
0147 
0148 // Exapnds to a tagged-argument constructor overload that passes the argument
0149 // pack to the base class delegate constructor.
0150 #define BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR_OVERLOAD_Z(z, n, data)           \
0151     template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename TaggedArg)>              \
0152     BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(n, 1), explicit) inline                  \
0153     BOOST_PP_TUPLE_ELEM(2, 0, data)(                                         \
0154         BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, TaggedArg, const& arg)           \
0155     ) : BOOST_PARAMETER_PARENTHESIZED_TYPE(BOOST_PP_TUPLE_ELEM(2, 1, data))( \
0156             ::boost::parameter::compose(BOOST_PP_ENUM_PARAMS_Z(z, n, arg))   \
0157         )                                                                    \
0158     {                                                                        \
0159     }
0160 /**/
0161 
0162 // Exapnds to a tagged-argument constructor overload that passes the argument
0163 // pack to the delegate function.
0164 #define BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR_OVERLOAD_Z(z, n, data)   \
0165     template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename TaggedArg)>              \
0166     BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(n, 1), explicit) inline                  \
0167     BOOST_PP_TUPLE_ELEM(2, 0, data)(                                         \
0168         BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, TaggedArg, const& a)             \
0169     )                                                                        \
0170     {                                                                        \
0171         BOOST_PP_TUPLE_ELEM(2, 1, data)(                                     \
0172             ::boost::parameter::compose(BOOST_PP_ENUM_PARAMS_Z(z, n, a))     \
0173         );                                                                   \
0174     }
0175 /**/
0176 
0177 #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
0178 
0179 // Exapnds to a tagged-argument function overload.
0180 #define BOOST_PARAMETER_NO_SPEC_FUNCTION_OVERLOAD_Z(z, n, data)              \
0181     template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename TaggedArg)>              \
0182     BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(4, 1, data))  \
0183     inline typename BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(            \
0184         BOOST_PP_TUPLE_ELEM(4, 1, data)                                      \
0185       , BOOST_PP_TUPLE_ELEM(4, 3, data)                                      \
0186     )<BOOST_PP_ENUM_PARAMS_Z(z, n, TaggedArg)>::type                         \
0187         BOOST_PARAMETER_MEMBER_FUNCTION_NAME(                                \
0188             BOOST_PP_TUPLE_ELEM(4, 0, data)                                  \
0189         )(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, TaggedArg, const& arg))        \
0190         BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(4, 3, data), const)             \
0191     {                                                                        \
0192         return BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(4, 2, data), this->)     \
0193         BOOST_PARAMETER_NO_SPEC_FUNCTION_IMPL_NAME(                          \
0194             BOOST_PP_TUPLE_ELEM(4, 1, data)                                  \
0195           , BOOST_PP_TUPLE_ELEM(4, 3, data)                                  \
0196         )(                                                                   \
0197             static_cast<                                                     \
0198                 typename BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(       \
0199                     BOOST_PP_TUPLE_ELEM(4, 1, data)                          \
0200                   , BOOST_PP_TUPLE_ELEM(4, 3, data)                          \
0201                 )<BOOST_PP_ENUM_PARAMS_Z(z, n, TaggedArg)>::type(*)()        \
0202             >(BOOST_PARAMETER_AUX_PP_NULLPTR)                                \
0203           , ::boost::parameter::compose(BOOST_PP_ENUM_PARAMS_Z(z, n, arg))   \
0204         );                                                                   \
0205     }
0206 /**/
0207 
0208 #else   // !defined(BOOST_NO_SFINAE)
0209 
0210 #include <boost/parameter/are_tagged_arguments.hpp>
0211 #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
0212 #include <boost/core/enable_if.hpp>
0213 
0214 // Exapnds to a tagged-argument constructor overload that passes the argument
0215 // pack to the base class delegate constructor.  This constructor is enabled
0216 // if and only if all its arguments are tagged arguments.
0217 #define BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR_OVERLOAD_Z(z, n, data)           \
0218     template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename TaggedArg)>              \
0219     BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(n, 1), explicit) inline                  \
0220     BOOST_PP_TUPLE_ELEM(2, 0, data)(                                         \
0221         BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, TaggedArg, const& arg)           \
0222       , typename ::boost::enable_if<                                         \
0223             ::boost::parameter::are_tagged_arguments<                        \
0224                 BOOST_PP_ENUM_PARAMS_Z(z, n, TaggedArg)                      \
0225             >                                                                \
0226         >::type* = BOOST_PARAMETER_AUX_PP_NULLPTR                            \
0227     ) : BOOST_PARAMETER_PARENTHESIZED_TYPE(BOOST_PP_TUPLE_ELEM(2, 1, data))( \
0228             ::boost::parameter::compose(BOOST_PP_ENUM_PARAMS_Z(z, n, arg))   \
0229         )                                                                    \
0230     {                                                                        \
0231     }
0232 /**/
0233 
0234 // Exapnds to a tagged-argument constructor overload that passes the argument
0235 // pack to the delegate function.  This constructor is enabled if and only if
0236 // all its arguments are tagged arguments.
0237 #define BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR_OVERLOAD_Z(z, n, data)   \
0238     template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename TaggedArg)>              \
0239     BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(n, 1), explicit) inline                  \
0240     BOOST_PP_TUPLE_ELEM(2, 0, data)(                                         \
0241         BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, TaggedArg, const& a)             \
0242       , typename ::boost::enable_if<                                         \
0243             ::boost::parameter::are_tagged_arguments<                        \
0244                 BOOST_PP_ENUM_PARAMS_Z(z, n, TaggedArg)                      \
0245             >                                                                \
0246         >::type* = BOOST_PARAMETER_AUX_PP_NULLPTR                            \
0247     )                                                                        \
0248     {                                                                        \
0249         BOOST_PP_TUPLE_ELEM(2, 1, data)(                                     \
0250             ::boost::parameter::compose(BOOST_PP_ENUM_PARAMS_Z(z, n, a))     \
0251         );                                                                   \
0252     }
0253 /**/
0254 
0255 // Exapnds to a function overload that is enabled if and only if
0256 // all its arguments are tagged arguments.
0257 #define BOOST_PARAMETER_NO_SPEC_FUNCTION_OVERLOAD_Z(z, n, data)              \
0258     template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename TaggedArg)>              \
0259     BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(4, 1, data))  \
0260     inline typename ::boost::lazy_enable_if<                                 \
0261         ::boost::parameter                                                   \
0262         ::are_tagged_arguments<BOOST_PP_ENUM_PARAMS_Z(z, n, TaggedArg)>      \
0263       , BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(                        \
0264             BOOST_PP_TUPLE_ELEM(4, 1, data)                                  \
0265           , BOOST_PP_TUPLE_ELEM(4, 3, data)                                  \
0266         )<BOOST_PP_ENUM_PARAMS_Z(z, n, TaggedArg)>                           \
0267     >::type BOOST_PARAMETER_MEMBER_FUNCTION_NAME(                            \
0268         BOOST_PP_TUPLE_ELEM(4, 0, data)                                      \
0269     )(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, TaggedArg, const& arg))            \
0270     BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(4, 3, data), const)                 \
0271     {                                                                        \
0272         return BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(4, 2, data), this->)     \
0273         BOOST_PARAMETER_NO_SPEC_FUNCTION_IMPL_NAME(                          \
0274             BOOST_PP_TUPLE_ELEM(4, 1, data)                                  \
0275           , BOOST_PP_TUPLE_ELEM(4, 3, data)                                  \
0276         )(                                                                   \
0277             static_cast<                                                     \
0278                 typename BOOST_PARAMETER_NO_SPEC_FUNCTION_RESULT_NAME(       \
0279                     BOOST_PP_TUPLE_ELEM(4, 1, data)                          \
0280                   , BOOST_PP_TUPLE_ELEM(4, 3, data)                          \
0281                 )<BOOST_PP_ENUM_PARAMS_Z(z, n, TaggedArg)>::type(*)()        \
0282             >(BOOST_PARAMETER_AUX_PP_NULLPTR)                                \
0283           , ::boost::parameter::compose(BOOST_PP_ENUM_PARAMS_Z(z, n, arg))   \
0284         );                                                                   \
0285     }
0286 /**/
0287 
0288 #endif  // BOOST_NO_SFINAE
0289 
0290 #include <boost/preprocessor/arithmetic/inc.hpp>
0291 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
0292 
0293 // Emulates a variadic constructor that is enabled if and only if all its
0294 // arguments are tagged arguments.  The enclosing class must inherit from the
0295 // specified base class, which in turn must implement a constructor that takes
0296 // in the argument pack that this one passes on.
0297 #define BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(class_, base)                    \
0298     BOOST_PP_REPEAT_FROM_TO(                                                 \
0299         1                                                                    \
0300       , BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY)                      \
0301       , BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR_OVERLOAD_Z                       \
0302       , (class_, base)                                                       \
0303     )
0304 /**/
0305 
0306 // Emulates a variadic constructor that is enabled if and only if all its
0307 // arguments are tagged arguments.  The specified function must be able to
0308 // take in the argument pack that this constructor passes on.
0309 #define BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(class_, func)            \
0310     BOOST_PP_REPEAT_FROM_TO(                                                 \
0311         1                                                                    \
0312       , BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY)                      \
0313       , BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR_OVERLOAD_Z               \
0314       , (class_, func)                                                       \
0315     )
0316 /**/
0317 
0318 // Emulates a variadic function that is enabled if and only if
0319 // all its arguments are tagged arguments.
0320 #define BOOST_PARAMETER_NO_SPEC_FUNCTION_OVERLOAD(name, impl, is_m, c)       \
0321     BOOST_PP_REPEAT_FROM_TO(                                                 \
0322         1                                                                    \
0323       , BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY)                      \
0324       , BOOST_PARAMETER_NO_SPEC_FUNCTION_OVERLOAD_Z                          \
0325       , (name, impl, is_m, c)                                                \
0326     )
0327 /**/
0328 
0329 #endif  // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
0330 #endif  // include guard
0331