Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:10:13

0001 // Boost.TypeErasure library
0002 //
0003 // Copyright 2012-2013 Steven Watanabe
0004 //
0005 // Distributed under the Boost Software License Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // $Id$
0010 
0011 #ifndef BOOST_TYPE_ERASURE_MEMBER_HPP_INCLUDED
0012 #define BOOST_TYPE_ERASURE_MEMBER_HPP_INCLUDED
0013 
0014 #include <boost/type_erasure/detail/member11.hpp>
0015 
0016 #ifndef BOOST_TYPE_ERASURE_MEMBER
0017 
0018 #include <boost/detail/workaround.hpp>
0019 #include <boost/preprocessor/cat.hpp>
0020 #include <boost/preprocessor/dec.hpp>
0021 #include <boost/preprocessor/comma_if.hpp>
0022 #include <boost/preprocessor/repetition/enum.hpp>
0023 #include <boost/preprocessor/repetition/enum_trailing.hpp>
0024 #include <boost/preprocessor/repetition/enum_params.hpp>
0025 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0026 #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
0027 #include <boost/preprocessor/seq/size.hpp>
0028 #include <boost/preprocessor/seq/elem.hpp>
0029 #include <boost/preprocessor/tuple/elem.hpp>
0030 #include <boost/type_erasure/detail/macro.hpp>
0031 #include <boost/type_erasure/detail/const.hpp>
0032 #include <boost/type_erasure/rebind_any.hpp>
0033 #include <boost/type_erasure/placeholder.hpp>
0034 #include <boost/type_erasure/call.hpp>
0035 #include <boost/type_erasure/concept_interface.hpp>
0036 
0037 /** INTERNAL ONLY */
0038 #define BOOST_TYPE_ERASURE_MEMBER_ARG(z, n, data)  \
0039     typename ::boost::type_erasure::as_param<Base, BOOST_PP_CAT(A, n)>::type BOOST_PP_CAT(a, n)
0040 
0041 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || \
0042     defined(BOOST_TYPE_ERASURE_DOXYGEN) || \
0043     BOOST_WORKAROUND(BOOST_MSVC, == 1800)
0044 
0045 /** INTERNAL ONLY */
0046 #define BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(seq, N) \
0047     BOOST_TYPE_ERASURE_QUALIFIED_NAME(seq)<R(BOOST_PP_ENUM_PARAMS(N, A)), T>
0048 
0049 /** INTERNAL ONLY */
0050 #define BOOST_TYPE_ERASURE_MEMBER_TPL_ARG_LIST(N, X) BOOST_PP_ENUM_TRAILING_PARAMS(N, X)
0051 /** INTERNAL ONLY */
0052 #define BOOST_TYPE_ERASURE_MEMBER_ENUM_PARAMS(N, X) BOOST_PP_ENUM_PARAMS(N, X)
0053 
0054 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0055 
0056 /** INTERNAL ONLY */
0057 #define BOOST_TYPE_ERASURE_MEMBER_FORWARD(z, n, data) ::std::forward<BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, data), n)>(BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, data), n))
0058 /** INTERNAL ONLY */
0059 #define BOOST_TYPE_ERASURE_MEMBER_FORWARD_PARAMS(N, X, x) BOOST_PP_ENUM(N, BOOST_TYPE_ERASURE_MEMBER_FORWARD, (X, x))
0060 /** INTERNAL ONLY*/
0061 #define BOOST_TYPE_ERASURE_FORWARD_REBIND1(z, n, data) ::std::forward<typename ::boost::type_erasure::as_param<Base, BOOST_PP_CAT(A, n)>::type>(BOOST_PP_CAT(a, n))
0062 /** INTERNAL ONLY*/
0063 #define BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N) BOOST_PP_ENUM_TRAILING(N, BOOST_TYPE_ERASURE_FORWARD_REBIND1, ~)
0064 
0065 #else
0066 
0067 /** INTERNAL ONLY */
0068 #define BOOST_TYPE_ERASURE_MEMBER_FORWARD_PARAMS(N, X, x) BOOST_PP_ENUM_PARAMS(N, x)
0069 /** INTERNAL ONLY*/
0070 #define BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N) BOOST_PP_ENUM_TRAILING_PARAMS(N, a)
0071 
0072 #endif
0073 
0074 /** INTERNAL ONLY */
0075 #define BOOST_TYPE_ERASURE_MEMBER_ENUM_TRAILING_PARAMS(N, X) BOOST_PP_ENUM_TRAILING_PARAMS(N, X)
0076 /** INTERNAL ONLY */
0077 #define BOOST_TYPE_ERASURE_MEMBER_ENUM_TRAILING_BINARY_PARAMS(N, X, x) BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, X, x)
0078 /** INTERNAL ONLY */
0079 #define BOOST_TYPE_ERASURE_MEMBER_ENUM_ARGS(N) BOOST_PP_ENUM(N, BOOST_TYPE_ERASURE_MEMBER_ARG, ~)
0080 
0081 #ifdef BOOST_TYPE_ERASURE_DOXYGEN
0082 
0083 /**
0084  * \brief Defines a primitive concept for a member function.
0085  *
0086  * \param concept_name is the name of the concept to declare.
0087  *        If it is omitted it defaults to <code>has_ ## member</code>
0088  * \param member is the name of the member function.
0089  *
0090  * The declaration of the concept is
0091  * \code
0092  * template<class Sig, class T = _self>
0093  * struct concept_name;
0094  * \endcode
0095  * where @c Sig is a function type giving the
0096  * signature of the member function, and @c T is the
0097  * object type.  @c T may be const-qualified for
0098  * const member functions.  @c concept_name<R(A...) const, T>
0099  * is an alias for @c concept_name<R(A...), const T>.
0100  *
0101  * This macro can only be used at namespace scope.
0102  *
0103  * Example:
0104  *
0105  * \code
0106  * namespace boost {
0107  * BOOST_TYPE_ERASURE_MEMBER(push_back)
0108  * }
0109  * typedef boost::has_push_back<void(int)> push_back_concept;
0110  * \endcode
0111  *
0112  * The concept defined by this function may be specialized to
0113  * provide a concept_map.  The class object will be passed by
0114  * reference as the first parameter.
0115  *
0116  * \code
0117  * template<>
0118  * struct has_push_back<void(int), std::list<int> > {
0119  *   static void apply(std::list<int>& l, int i) { l.push_back(i); }
0120  * };
0121  * \endcode
0122  *
0123  * In C++03, the macro can only be used in the global namespace and
0124  * is defined as:
0125  *
0126  * \code
0127  * #define BOOST_TYPE_ERASURE_MEMBER(qualified_name, member, N)
0128  * \endcode
0129  *
0130  * Example:
0131  *
0132  * \code
0133  * BOOST_TYPE_ERASURE_MEMBER((boost)(has_push_back), push_back, 1)
0134  * typedef boost::has_push_back<void(int), _self> push_back_concept;
0135  * \endcode
0136  *
0137  * For backwards compatibility, this form is always accepted.
0138  */
0139 #define BOOST_TYPE_ERASURE_MEMBER(concept_name, member) /**/
0140 
0141 #else
0142 
0143 #define BOOST_TYPE_ERASURE_MEMBER(qualified_name, member, N)                                \
0144     BOOST_TYPE_ERASURE_MEMBER_I(                                                            \
0145         qualified_name,                                                                     \
0146         BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(qualified_name)), qualified_name), \
0147         member,                                                                             \
0148         N)
0149 
0150 #endif
0151 
0152 #else
0153 
0154 /** INTERNAL ONLY */
0155 #define BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(seq, N) \
0156     BOOST_TYPE_ERASURE_QUALIFIED_NAME(seq)<R(A...), T>
0157 
0158 #define BOOST_TYPE_ERASURE_MEMBER_TPL_ARG_LIST(N, X) , class... A
0159 #define BOOST_TYPE_ERASURE_MEMBER_ENUM_PARAMS(N, X) X...
0160 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0161 #   define BOOST_TYPE_ERASURE_MEMBER_FORWARD_PARAMS(N, X, x) ::std::forward<X>(x)...
0162 #   define BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N) , ::std::forward<typename ::boost::type_erasure::as_param<Base, A>::type>(a)...
0163 #else
0164 #   define BOOST_TYPE_ERASURE_MEMBER_FORWARD_PARAMS(N, X, x) x...
0165 #   define BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N) , a...
0166 #endif
0167 #define BOOST_TYPE_ERASURE_MEMBER_ENUM_TRAILING_PARAMS(N, X) , X...
0168 #define BOOST_TYPE_ERASURE_MEMBER_ENUM_TRAILING_BINARY_PARAMS(N, X, x) , X... x
0169 #define BOOST_TYPE_ERASURE_MEMBER_ENUM_ARGS(N) typename ::boost::type_erasure::as_param<Base, A>::type... a
0170 
0171 
0172 #define BOOST_TYPE_ERASURE_MEMBER(qualified_name, member, ...)                              \
0173     BOOST_TYPE_ERASURE_MEMBER_I(                                                            \
0174         qualified_name,                                                                     \
0175         BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(qualified_name)), qualified_name), \
0176         member,                                                                             \
0177         N)
0178 
0179 #endif
0180 
0181 /** INTERNAL ONLY */
0182 #define BOOST_TYPE_ERASURE_MEMBER_II(qual_name, concept_name, member, N)                        \
0183     BOOST_TYPE_ERASURE_OPEN_NAMESPACE(qual_name)                                                \
0184     template<class Sig, class T = ::boost::type_erasure::_self>                                 \
0185     struct concept_name;                                                                        \
0186     template<class R BOOST_TYPE_ERASURE_MEMBER_TPL_ARG_LIST(N, class A), class T>               \
0187     struct concept_name<R(BOOST_TYPE_ERASURE_MEMBER_ENUM_PARAMS(N, A)), T> {                    \
0188         static R apply(T& t BOOST_TYPE_ERASURE_MEMBER_ENUM_TRAILING_BINARY_PARAMS(N, A, a))     \
0189         { return t.member(BOOST_TYPE_ERASURE_MEMBER_FORWARD_PARAMS(N, A, a)); }                 \
0190     };                                                                                          \
0191     template<class T BOOST_TYPE_ERASURE_MEMBER_TPL_ARG_LIST(N, class A)>                        \
0192     struct concept_name<void(BOOST_TYPE_ERASURE_MEMBER_ENUM_PARAMS(N, A)), T> {                 \
0193         static void apply(T& t BOOST_TYPE_ERASURE_MEMBER_ENUM_TRAILING_BINARY_PARAMS(N, A, a))  \
0194         { t.member(BOOST_TYPE_ERASURE_MEMBER_FORWARD_PARAMS(N, A, a)); }                        \
0195     };                                                                                          \
0196     BOOST_TYPE_ERASURE_CLOSE_NAMESPACE(qual_name)                                               \
0197     namespace boost {                                                                           \
0198     namespace type_erasure {                                                                    \
0199     template<                                                                                   \
0200         class R BOOST_TYPE_ERASURE_MEMBER_TPL_ARG_LIST(N, class A),                             \
0201         class T, class Base, class Enable>                                                      \
0202     struct concept_interface<                                                                   \
0203         BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(qual_name, N),                                   \
0204         Base,                                                                                   \
0205         typename ::boost::enable_if<                                                            \
0206             ::boost::type_erasure::detail::should_be_non_const<T, Base>,                        \
0207             typename ::boost::remove_const<T>::type                                             \
0208         >::type,                                                                                \
0209         Enable                                                                                  \
0210     > : Base                                                                                    \
0211     {                                                                                           \
0212         typedef void BOOST_PP_CAT(_boost_type_erasure_has_member, member);                      \
0213         typename rebind_any<Base, R>::type member(                                              \
0214             BOOST_TYPE_ERASURE_MEMBER_ENUM_ARGS(N))                                             \
0215         {                                                                                       \
0216             return ::boost::type_erasure::call(                                                 \
0217                 BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(qual_name, N)(),                         \
0218                 *this BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N));                             \
0219         }                                                                                       \
0220     };                                                                                          \
0221     template<                                                                                   \
0222         class R BOOST_TYPE_ERASURE_MEMBER_TPL_ARG_LIST(N, class A),                             \
0223         class T, class Base, class Enable>                                                      \
0224     struct concept_interface<                                                                   \
0225         BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(qual_name, N),                                   \
0226         Base,                                                                                   \
0227         typename ::boost::enable_if<                                                            \
0228             ::boost::type_erasure::detail::should_be_const<T, Base>,                            \
0229             typename ::boost::remove_const<T>::type                                             \
0230         >::type,                                                                                \
0231         Enable                                                                                  \
0232     > : Base                                                                                    \
0233     {                                                                                           \
0234         typedef void BOOST_PP_CAT(_boost_type_erasure_has_member, member);                      \
0235         typename rebind_any<Base, R>::type member(                                              \
0236             BOOST_TYPE_ERASURE_MEMBER_ENUM_ARGS(N)) const                                       \
0237         {                                                                                       \
0238             return ::boost::type_erasure::call(                                                 \
0239                 BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(qual_name, N)(),                         \
0240                 *this BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N));                             \
0241         }                                                                                       \
0242     };                                                                                          \
0243     template<class R BOOST_TYPE_ERASURE_MEMBER_TPL_ARG_LIST(N, class A), class T, class Base>   \
0244     struct concept_interface<                                                                   \
0245         BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(qual_name, N),                                   \
0246         Base,                                                                                   \
0247         typename ::boost::enable_if<                                                            \
0248             ::boost::type_erasure::detail::should_be_non_const<T, Base>,                        \
0249             typename ::boost::remove_const<T>::type                                             \
0250         >::type,                                                                                \
0251         typename Base::BOOST_PP_CAT(_boost_type_erasure_has_member, member)> : Base             \
0252     {                                                                                           \
0253         using Base::member;                                                                     \
0254         typename rebind_any<Base, R>::type member(                                              \
0255             BOOST_TYPE_ERASURE_MEMBER_ENUM_ARGS(N))                                             \
0256         {                                                                                       \
0257             return ::boost::type_erasure::call(                                                 \
0258                 BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(qual_name, N)(),                         \
0259                 *this BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N));                             \
0260         }                                                                                       \
0261     };                                                                                          \
0262     template<class R BOOST_TYPE_ERASURE_MEMBER_TPL_ARG_LIST(N, class A), class T, class Base>   \
0263     struct concept_interface<                                                                   \
0264         BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(qual_name, N),                                   \
0265         Base,                                                                                   \
0266         typename ::boost::enable_if<                                                            \
0267             ::boost::type_erasure::detail::should_be_const<T, Base>,                            \
0268             typename ::boost::remove_const<T>::type                                             \
0269         >::type,                                                                                \
0270         typename Base::BOOST_PP_CAT(_boost_type_erasure_has_member, member)> : Base             \
0271     {                                                                                           \
0272         using Base::member;                                                                     \
0273         typename rebind_any<Base, R>::type member(                                              \
0274             BOOST_TYPE_ERASURE_MEMBER_ENUM_ARGS(N)) const                                       \
0275         {                                                                                       \
0276             return ::boost::type_erasure::call(                                                 \
0277                 BOOST_TYPE_ERASURE_MEMBER_QUALIFIED_ID(qual_name, N)(),                         \
0278                 *this BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N));                             \
0279         }                                                                                       \
0280     };                                                                                          \
0281     }}
0282 
0283 /** INTERNAL ONLY */
0284 #define BOOST_TYPE_ERASURE_MEMBER_I(namespace_name, concept_name, member, N)\
0285     BOOST_TYPE_ERASURE_MEMBER_II(namespace_name, concept_name, member, N)
0286 
0287 #endif
0288 
0289 #endif