|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2007-12-17 15:13:33
Author: eric_niebler
Date: 2007-12-17 15:13:33 EST (Mon, 17 Dec 2007)
New Revision: 42132
URL: http://svn.boost.org/trac/boost/changeset/42132
Log:
port nary_expr and function to c++03
Added:
branches/proto/v3/boost/xpressive/proto/detail/nary_expr.hpp (contents, props changed)
Text files modified:
branches/proto/v3/boost/xpressive/proto/traits.hpp | 35 +----------------------------------
1 files changed, 1 insertions(+), 34 deletions(-)
Added: branches/proto/v3/boost/xpressive/proto/detail/nary_expr.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/nary_expr.hpp 2007-12-17 15:13:33 EST (Mon, 17 Dec 2007)
@@ -0,0 +1,120 @@
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file nary_expr.hpp
+ /// Definintion of nary_expr<> and function<>
+ //
+ // Copyright 2007 Eric Niebler. Distributed under the Boost
+ // Software License, Version 1.0. (See accompanying file
+ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+ #ifndef BOOST_PROTO_DETAIL_NARY_EXPR_HPP_EAN_11_07_2007
+ #define BOOST_PROTO_DETAIL_NARY_EXPR_HPP_EAN_11_07_2007
+
+ #include <boost/mpl/bool.hpp>
+ #include <boost/type_traits.hpp>
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/detail/apply_args.hpp>
+ #include <boost/xpressive/proto/detail/define.hpp>
+
+ namespace boost { namespace proto
+ {
+ namespace op
+ {
+
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A), typename... Rest>
+ struct nary_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A), Rest...>
+ {
+ typedef expr<Tag, args<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, A), Rest...> > type;
+ typedef type proto_base_expr;
+
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef detail::apply_args<
+ UNREF(Expr)::proto_args
+ , State
+ , Visitor
+ , args<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, A), Rest...>
+ > apply_;
+ typedef expr<UNREF(Expr)::proto_tag, typename apply_::type> type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<nary_expr(Expr const &, State const &, Visitor &)>::type
+ operator()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ typedef result<nary_expr(Expr const &, State const &, Visitor &)> result_;
+ typename result_::type that = {
+ result_::apply_::call(expr.proto_base().proto_args_, state, visitor)
+ };
+ return that;
+ }
+ };
+
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename A), typename... Rest>
+ struct function<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, A), Rest...>
+ : nary_expr<tag::function BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A), Rest...>
+ {};
+
+ #endif
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/detail/nary_expr.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ }
+ }}
+
+ #include <boost/xpressive/proto/detail/undef.hpp>
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct nary_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, A)>
+ {
+ typedef expr<Tag, args<BOOST_PP_ENUM_PARAMS(N, A)> > type;
+ typedef type proto_base_expr;
+
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef detail::apply_args<
+ UNREF(Expr)::proto_args
+ , State
+ , Visitor
+ #define TMP(Z, M, DATA) , BOOST_PP_CAT(A, BOOST_PP_DEC(N))
+ , args<BOOST_PP_ENUM_PARAMS(N, A) BOOST_PP_REPEAT_FROM_TO(N, BOOST_PROTO_MAX_ARITY, TMP, ~)>
+ #undef TMP
+ > apply_;
+ typedef expr<UNREF(Expr)::proto_tag, typename apply_::type> type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<nary_expr(Expr const &, State const &, Visitor &)>::type
+ operator()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ typedef result<nary_expr(Expr const &, State const &, Visitor &)> result_;
+ typename result_::type that = {
+ result_::apply_::call(expr.proto_base().proto_args_, state, visitor)
+ };
+ return that;
+ }
+ };
+
+ template<BOOST_PP_ENUM_PARAMS(N, typename A)>
+ struct function<BOOST_PP_ENUM_PARAMS(N, A)>
+ : nary_expr<tag::function BOOST_PP_ENUM_TRAILING_PARAMS(N, A)>
+ {};
+
+ #undef N
+
+#endif
Modified: branches/proto/v3/boost/xpressive/proto/traits.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/traits.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/traits.hpp 2007-12-17 15:13:33 EST (Mon, 17 Dec 2007)
@@ -14,6 +14,7 @@
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/args.hpp>
#include <boost/xpressive/proto/detail/apply_args.hpp>
+#include <boost/xpressive/proto/detail/nary_expr.hpp>
#include <boost/xpressive/proto/detail/is_callable.hpp>
#include <boost/xpressive/proto/detail/define.hpp>
@@ -150,40 +151,6 @@
template<typename T, typename U> struct bitwise_xor_assign : binary_expr<tag::bitwise_xor_assign, T, U> {};
template<typename T, typename U> struct subscript : binary_expr<tag::subscript, T, U> {};
- template<typename Tag, typename... Args>
- struct nary_expr
- {
- typedef expr<Tag, args<Args...> > type;
- typedef type proto_base_expr;
-
- template<typename Sig>
- struct result;
-
- template<typename This, typename Expr, typename State, typename Visitor>
- struct result<This(Expr, State, Visitor)>
- {
- typedef typename detail::pad_args<Args...>::type padded_args;
- typedef detail::apply_args<UNREF(Expr)::proto_args, State, Visitor, padded_args> apply_;
- typedef expr<UNREF(Expr)::proto_tag, typename apply_::type> type;
- };
-
- template<typename Expr, typename State, typename Visitor>
- typename result<nary_expr(Expr const &, State const &, Visitor &)>::type
- operator()(Expr const &expr, State const &state, Visitor &visitor) const
- {
- typedef result<nary_expr(Expr const &, State const &, Visitor &)> result_;
- typename result_::type that = {
- result_::apply_::call(expr.proto_base().proto_args_, state, visitor)
- };
- return that;
- }
- };
-
- template<typename... Args>
- struct function
- : nary_expr<tag::function, Args...>
- {};
-
}
namespace result_of
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk