Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:26

0001 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
0002 
0003     #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
0004         #include <boost/proto/detail/preprocessed/expr_variadic.hpp>
0005     #else
0006         #include <boost/proto/detail/preprocessed/expr.hpp>
0007     #endif
0008 
0009 #elif !defined(BOOST_PP_IS_ITERATING)
0010 
0011     /// INTERNAL ONLY
0012     ///
0013     #define BOOST_PROTO_CHILD(Z, N, DATA)                                                       \
0014         typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(proto_child, N);                              \
0015         BOOST_PP_CAT(proto_child, N) BOOST_PP_CAT(child, N);                                    \
0016         /**< INTERNAL ONLY */
0017 
0018     /// INTERNAL ONLY
0019     ///
0020     #define BOOST_PROTO_VOID(Z, N, DATA)                                                        \
0021         typedef void BOOST_PP_CAT(proto_child, N);                                              \
0022         /**< INTERNAL ONLY */
0023 
0024     // Generate variadic versions of expr
0025     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0026         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/expr_variadic.hpp")
0027     #endif
0028 
0029     ///////////////////////////////////////////////////////////////////////////////
0030     /// \file expr_variadic.hpp
0031     /// Contains definition of expr\<\> class template.
0032     //
0033     //  Copyright 2008 Eric Niebler. Distributed under the Boost
0034     //  Software License, Version 1.0. (See accompanying file
0035     //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0036 
0037     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0038         #pragma wave option(preserve: 1)
0039     #endif
0040 
0041     // The expr<> specializations are actually defined here.
0042     #define BOOST_PROTO_DEFINE_TERMINAL
0043     #define BOOST_PP_ITERATION_PARAMS_1                                                         \
0044         (3, (0, 0, <boost/proto/detail/expr.hpp>))
0045     #include BOOST_PP_ITERATE()
0046 
0047     #undef BOOST_PROTO_DEFINE_TERMINAL
0048     #define BOOST_PP_ITERATION_PARAMS_1                                                         \
0049         (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/expr.hpp>))
0050     #include BOOST_PP_ITERATE()
0051 
0052     // Generate non-variadic versions of expr
0053     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0054         #define BOOST_NO_CXX11_VARIADIC_TEMPLATES
0055         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/expr.hpp")
0056 
0057         ///////////////////////////////////////////////////////////////////////////////
0058         /// \file expr.hpp
0059         /// Contains definition of expr\<\> class template.
0060         //
0061         //  Copyright 2008 Eric Niebler. Distributed under the Boost
0062         //  Software License, Version 1.0. (See accompanying file
0063         //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0064 
0065         #pragma wave option(preserve: 1)
0066 
0067         // The expr<> specializations are actually defined here.
0068         #define BOOST_PROTO_DEFINE_TERMINAL
0069         #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, <boost/proto/detail/expr.hpp>))
0070         #include BOOST_PP_ITERATE()
0071 
0072         #undef BOOST_PROTO_DEFINE_TERMINAL
0073         #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/expr.hpp>))
0074         #include BOOST_PP_ITERATE()
0075 
0076         #pragma wave option(output: null)
0077         #undef BOOST_NO_CXX11_VARIADIC_TEMPLATES
0078     #endif
0079 
0080     #undef BOOST_PROTO_CHILD
0081     #undef BOOST_PROTO_VOID
0082 
0083 #else
0084 
0085     #define ARG_COUNT BOOST_PP_MAX(1, BOOST_PP_ITERATION())
0086 
0087     /// \brief Representation of a node in an expression tree.
0088     ///
0089     /// \c proto::expr\<\> is a node in an expression template tree. It
0090     /// is a container for its child sub-trees. It also serves as
0091     /// the terminal nodes of the tree.
0092     ///
0093     /// \c Tag is type that represents the operation encoded by
0094     ///             this expression. It is typically one of the structs
0095     ///             in the \c boost::proto::tag namespace, but it doesn't
0096     ///             have to be.
0097     ///
0098     /// \c Args is a type list representing the type of the children
0099     ///             of this expression. It is an instantiation of one
0100     ///             of \c proto::list1\<\>, \c proto::list2\<\>, etc. The
0101     ///             child types must all themselves be either \c expr\<\>
0102     ///             or <tt>proto::expr\<\>&</tt>. If \c Args is an
0103     ///             instantiation of \c proto::term\<\> then this
0104     ///             \c expr\<\> type represents a terminal expression;
0105     ///             the parameter to the \c proto::term\<\> template
0106     ///             represents the terminal's value type.
0107     ///
0108     /// \c Arity is an integral constant representing the number of child
0109     ///             nodes this node contains. If \c Arity is 0, then this
0110     ///             node is a terminal.
0111     ///
0112     /// \c proto::expr\<\> is a valid Fusion random-access sequence, where
0113     /// the elements of the sequence are the child expressions.
0114     #ifdef BOOST_PROTO_DEFINE_TERMINAL
0115     template<typename Tag, typename Arg0>
0116     struct expr<Tag, term<Arg0>, 0>
0117     #else
0118     template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(ARG_COUNT, typename Arg)>
0119     struct expr<Tag, BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)>, BOOST_PP_ITERATION() >
0120     #endif
0121     {
0122         typedef Tag proto_tag;
0123         static const long proto_arity_c = BOOST_PP_ITERATION();
0124         typedef mpl::long_<BOOST_PP_ITERATION() > proto_arity;
0125         typedef expr proto_base_expr;
0126         #ifdef BOOST_PROTO_DEFINE_TERMINAL
0127         typedef term<Arg0> proto_args;
0128         #else
0129         typedef BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)> proto_args;
0130         #endif
0131         typedef basic_expr<Tag, proto_args, BOOST_PP_ITERATION() > proto_grammar;
0132         typedef default_domain proto_domain;
0133         typedef default_generator proto_generator;
0134         typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag;
0135         typedef expr proto_derived_expr;
0136         typedef void proto_is_expr_; /**< INTERNAL ONLY */
0137 
0138         BOOST_PP_REPEAT(ARG_COUNT, BOOST_PROTO_CHILD, ~)
0139         BOOST_PP_REPEAT_FROM_TO(ARG_COUNT, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)
0140 
0141         /// \return *this
0142         ///
0143         BOOST_FORCEINLINE
0144         expr const &proto_base() const
0145         {
0146             return *this;
0147         }
0148 
0149         /// \overload
0150         ///
0151         BOOST_FORCEINLINE
0152         expr &proto_base()
0153         {
0154             return *this;
0155         }
0156 
0157     #ifdef BOOST_PROTO_DEFINE_TERMINAL
0158         /// \return A new \c expr\<\> object initialized with the specified
0159         /// arguments.
0160         ///
0161         template<typename A0>
0162         BOOST_FORCEINLINE
0163         static expr const make(A0 &a0)
0164         {
0165             return detail::make_terminal(a0, static_cast<expr *>(0), static_cast<proto_args *>(0));
0166         }
0167 
0168         /// \overload
0169         ///
0170         template<typename A0>
0171         BOOST_FORCEINLINE
0172         static expr const make(A0 const &a0)
0173         {
0174             return detail::make_terminal(a0, static_cast<expr *>(0), static_cast<proto_args *>(0));
0175         }
0176     #else
0177         /// \return A new \c expr\<\> object initialized with the specified
0178         /// arguments.
0179         ///
0180         template<BOOST_PP_ENUM_PARAMS(ARG_COUNT, typename A)>
0181         BOOST_FORCEINLINE
0182         static expr const make(BOOST_PP_ENUM_BINARY_PARAMS(ARG_COUNT, A, const &a))
0183         {
0184             expr that = {BOOST_PP_ENUM_PARAMS(ARG_COUNT, a)};
0185             return that;
0186         }
0187     #endif
0188 
0189     #if 1 == BOOST_PP_ITERATION()
0190         /// If \c Tag is \c boost::proto::tag::address_of and \c proto_child0 is
0191         /// <tt>T&</tt>, then \c address_of_hack_type_ is <tt>T*</tt>.
0192         /// Otherwise, it is some undefined type.
0193         typedef typename detail::address_of_hack<Tag, proto_child0>::type address_of_hack_type_;
0194 
0195         /// \return The address of <tt>this->child0</tt> if \c Tag is
0196         /// \c boost::proto::tag::address_of. Otherwise, this function will
0197         /// fail to compile.
0198         ///
0199         /// \attention Proto overloads <tt>operator&</tt>, which means that
0200         /// proto-ified objects cannot have their addresses taken, unless we use
0201         /// the following hack to make \c &x implicitly convertible to \c X*.
0202         BOOST_FORCEINLINE
0203         operator address_of_hack_type_() const
0204         {
0205             return boost::addressof(this->child0);
0206         }
0207     #else
0208         /// INTERNAL ONLY
0209         ///
0210         typedef detail::not_a_valid_type address_of_hack_type_;
0211     #endif
0212 
0213         /// Assignment
0214         ///
0215         /// \param a The rhs.
0216         /// \return A new \c expr\<\> node representing an assignment of \c that to \c *this.
0217         BOOST_FORCEINLINE
0218         proto::expr<
0219             proto::tag::assign
0220           , list2<expr &, expr const &>
0221           , 2
0222         > const
0223         operator =(expr const &a)
0224         {
0225             proto::expr<
0226                 proto::tag::assign
0227               , list2<expr &, expr const &>
0228               , 2
0229             > that = {*this, a};
0230             return that;
0231         }
0232 
0233         /// Assignment
0234         ///
0235         /// \param a The rhs.
0236         /// \return A new \c expr\<\> node representing an assignment of \c a to \c *this.
0237         template<typename A>
0238         BOOST_FORCEINLINE
0239         proto::expr<
0240             proto::tag::assign
0241           , list2<expr const &, typename result_of::as_child<A>::type>
0242           , 2
0243         > const
0244         operator =(A &a) const
0245         {
0246             proto::expr<
0247                 proto::tag::assign
0248               , list2<expr const &, typename result_of::as_child<A>::type>
0249               , 2
0250             > that = {*this, proto::as_child(a)};
0251             return that;
0252         }
0253 
0254         /// \overload
0255         ///
0256         template<typename A>
0257         BOOST_FORCEINLINE
0258         proto::expr<
0259             proto::tag::assign
0260           , list2<expr const &, typename result_of::as_child<A const>::type>
0261           , 2
0262         > const
0263         operator =(A const &a) const
0264         {
0265             proto::expr<
0266                 proto::tag::assign
0267               , list2<expr const &, typename result_of::as_child<A const>::type>
0268               , 2
0269             > that = {*this, proto::as_child(a)};
0270             return that;
0271         }
0272 
0273     #ifdef BOOST_PROTO_DEFINE_TERMINAL
0274         /// \overload
0275         ///
0276         template<typename A>
0277         BOOST_FORCEINLINE
0278         proto::expr<
0279             proto::tag::assign
0280           , list2<expr &, typename result_of::as_child<A>::type>
0281           , 2
0282         > const
0283         operator =(A &a)
0284         {
0285             proto::expr<
0286                 proto::tag::assign
0287               , list2<expr &, typename result_of::as_child<A>::type>
0288               , 2
0289             > that = {*this, proto::as_child(a)};
0290             return that;
0291         }
0292 
0293         /// \overload
0294         ///
0295         template<typename A>
0296         BOOST_FORCEINLINE
0297         proto::expr<
0298             proto::tag::assign
0299           , list2<expr &, typename result_of::as_child<A const>::type>
0300           , 2
0301         > const
0302         operator =(A const &a)
0303         {
0304             proto::expr<
0305                 proto::tag::assign
0306               , list2<expr &, typename result_of::as_child<A const>::type>
0307               , 2
0308             > that = {*this, proto::as_child(a)};
0309             return that;
0310         }
0311     #endif
0312 
0313         /// Subscript
0314         ///
0315         /// \param a The rhs.
0316         /// \return A new \c expr\<\> node representing \c *this subscripted with \c a.
0317         template<typename A>
0318         BOOST_FORCEINLINE
0319         proto::expr<
0320             proto::tag::subscript
0321           , list2<expr const &, typename result_of::as_child<A>::type>
0322           , 2
0323         > const
0324         operator [](A &a) const
0325         {
0326             proto::expr<
0327                 proto::tag::subscript
0328               , list2<expr const &, typename result_of::as_child<A>::type>
0329               , 2
0330             > that = {*this, proto::as_child(a)};
0331             return that;
0332         }
0333 
0334         /// \overload
0335         ///
0336         template<typename A>
0337         BOOST_FORCEINLINE
0338         proto::expr<
0339             proto::tag::subscript
0340           , list2<expr const &, typename result_of::as_child<A const>::type>
0341           , 2
0342         > const
0343         operator [](A const &a) const
0344         {
0345             proto::expr<
0346                 proto::tag::subscript
0347               , list2<expr const &, typename result_of::as_child<A const>::type>
0348               , 2
0349             > that = {*this, proto::as_child(a)};
0350             return that;
0351         }
0352 
0353     #ifdef BOOST_PROTO_DEFINE_TERMINAL
0354         /// \overload
0355         ///
0356         template<typename A>
0357         BOOST_FORCEINLINE
0358         proto::expr<
0359             proto::tag::subscript
0360           , list2<expr &, typename result_of::as_child<A>::type>
0361           , 2
0362         > const
0363         operator [](A &a)
0364         {
0365             proto::expr<
0366                 proto::tag::subscript
0367               , list2<expr &, typename result_of::as_child<A>::type>
0368               , 2
0369             > that = {*this, proto::as_child(a)};
0370             return that;
0371         }
0372 
0373         /// \overload
0374         ///
0375         template<typename A>
0376         BOOST_FORCEINLINE
0377         proto::expr<
0378             proto::tag::subscript
0379           , list2<expr &, typename result_of::as_child<A const>::type>
0380           , 2
0381         > const
0382         operator [](A const &a)
0383         {
0384             proto::expr<
0385                 proto::tag::subscript
0386               , list2<expr &, typename result_of::as_child<A const>::type>
0387               , 2
0388             > that = {*this, proto::as_child(a)};
0389             return that;
0390         }
0391     #endif
0392 
0393         /// Encodes the return type of \c expr\<\>::operator(), for use with \c boost::result_of\<\>
0394         ///
0395         template<typename Sig>
0396         struct result
0397         {
0398             typedef typename result_of::funop<Sig, expr, default_domain>::type const type;
0399         };
0400 
0401     #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
0402         /// \overload
0403         ///
0404         template<typename ...A>
0405         BOOST_FORCEINLINE
0406         typename result_of::funop<
0407             expr const(A const &...)
0408           , expr
0409           , default_domain
0410         >::type const
0411         operator ()(A const &... a) const
0412         {
0413             return result_of::funop<
0414                 expr const(A const &...)
0415               , expr
0416               , default_domain
0417             >::call(*this, a...);
0418         }
0419 
0420     #ifdef BOOST_PROTO_DEFINE_TERMINAL
0421         /// \overload
0422         ///
0423         template<typename ...A>
0424         BOOST_FORCEINLINE
0425         typename result_of::funop<
0426             expr(A const &...)
0427           , expr
0428           , default_domain
0429         >::type const
0430         operator ()(A const &... a)
0431         {
0432             return result_of::funop<
0433                 expr(A const &...)
0434               , expr
0435               , default_domain
0436             >::call(*this, a...);
0437         }
0438     #endif
0439 
0440     #else // BOOST_NO_CXX11_VARIADIC_TEMPLATES
0441 
0442         /// Function call
0443         ///
0444         /// \return A new \c expr\<\> node representing the function invocation of \c (*this)().
0445         BOOST_FORCEINLINE
0446         proto::expr<proto::tag::function, list1<expr const &>, 1> const
0447         operator ()() const
0448         {
0449             proto::expr<proto::tag::function, list1<expr const &>, 1> that = {*this};
0450             return that;
0451         }
0452 
0453     #ifdef BOOST_PROTO_DEFINE_TERMINAL
0454         /// \overload
0455         ///
0456         BOOST_FORCEINLINE
0457         proto::expr<proto::tag::function, list1<expr &>, 1> const
0458         operator ()()
0459         {
0460             proto::expr<proto::tag::function, list1<expr &>, 1> that = {*this};
0461             return that;
0462         }
0463     #endif
0464 
0465     #define BOOST_PP_ITERATION_PARAMS_2                                                             \
0466         (3, (1, BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY), <boost/proto/detail/expr_funop.hpp>))
0467     #include BOOST_PP_ITERATE()
0468 
0469 #endif
0470     };
0471 
0472 #undef ARG_COUNT
0473 
0474 #endif