|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62739 - in branches/release: . boost boost/algorithm/string boost/archive boost/bimap boost/config boost/detail boost/filesystem boost/functional/hash boost/fusion boost/gil boost/graph boost/integer boost/interprocess boost/intrusive boost/iostreams boost/math boost/numeric/ublas boost/program_options boost/property_tree boost/proto boost/proto/detail boost/proto/transform boost/python boost/range boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/support boost/statechart boost/system boost/thread boost/tr1 boost/type_traits boost/unordered boost/utility boost/uuid boost/variant boost/wave doc libs libs/array/doc libs/array/test libs/bimap libs/config libs/filesystem libs/functional/hash libs/fusion libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/iostreams libs/math libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/numeric/ublas libs/numeric/ublas/doc libs/program_options libs/property_tree libs/proto/doc libs/proto/doc/reference libs/proto/doc/reference/concepts libs/proto/doc/reference/transform libs/proto/test libs/python libs/range libs/range/doc libs/regex libs/regex/doc libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/statechart libs/static_assert libs/system libs/thread libs/timer libs/tr1 libs/type_traits libs/unordered libs/utility libs/utility/swap/test libs/uuid libs/wave more more/getting_started people status tools tools/bcp tools/boostbook tools/build/v2 tools/build/v2/tools tools/inspect tools/jam tools/quickbook tools/regression tools/release tools/wave wiki
From: eric_at_[hidden]
Date: 2010-06-10 11:03:31
Author: eric_niebler
Date: 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
New Revision: 62739
URL: http://svn.boost.org/trac/boost/changeset/62739
Log:
Merged revisions 62550,62616,62618 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r62550 | eric_niebler | 2010-06-08 01:07:00 -0400 (Tue, 08 Jun 2010) | 1 line
namespace reform, begin to make proto internals rely less on proto::expr
........
r62616 | eric_niebler | 2010-06-08 20:14:39 -0400 (Tue, 08 Jun 2010) | 1 line
use basic_expr instead of expr when possible for better compile times
........
r62618 | eric_niebler | 2010-06-08 20:23:57 -0400 (Tue, 08 Jun 2010) | 1 line
more namespace reform
........
Properties modified:
branches/release/ (props changed)
branches/release/INSTALL (props changed)
branches/release/Jamroot (props changed)
branches/release/LICENSE_1_0.txt (props changed)
branches/release/boost/ (props changed)
branches/release/boost-build.jam (props changed)
branches/release/boost.css (props changed)
branches/release/boost.png (props changed)
branches/release/boost/algorithm/string/ (props changed)
branches/release/boost/archive/ (props changed)
branches/release/boost/array.hpp (props changed)
branches/release/boost/bimap/ (props changed)
branches/release/boost/config/ (props changed)
branches/release/boost/config.hpp (props changed)
branches/release/boost/detail/ (props changed)
branches/release/boost/detail/endian.hpp (props changed)
branches/release/boost/filesystem/ (props changed)
branches/release/boost/functional/hash/ (props changed)
branches/release/boost/fusion/ (props changed)
branches/release/boost/gil/ (props changed)
branches/release/boost/graph/ (props changed)
branches/release/boost/integer/ (props changed)
branches/release/boost/interprocess/ (props changed)
branches/release/boost/intrusive/ (props changed)
branches/release/boost/iostreams/ (props changed)
branches/release/boost/math/ (props changed)
branches/release/boost/numeric/ublas/ (props changed)
branches/release/boost/program_options/ (props changed)
branches/release/boost/property_tree/ (props changed)
branches/release/boost/python/ (props changed)
branches/release/boost/range/ (props changed)
branches/release/boost/regex/ (props changed)
branches/release/boost/serialization/ (props changed)
branches/release/boost/serialization/factory.hpp (props changed)
branches/release/boost/signals/ (props changed)
branches/release/boost/signals2/ (props changed)
branches/release/boost/spirit/ (props changed)
branches/release/boost/spirit/home/ (props changed)
branches/release/boost/spirit/home/karma/ (props changed)
branches/release/boost/spirit/home/support/attributes.hpp (props changed)
branches/release/boost/statechart/ (props changed)
branches/release/boost/system/ (props changed)
branches/release/boost/thread/ (props changed)
branches/release/boost/thread.hpp (props changed)
branches/release/boost/tr1/ (props changed)
branches/release/boost/type_traits/ (props changed)
branches/release/boost/unordered/ (props changed)
branches/release/boost/utility/ (props changed)
branches/release/boost/utility/value_init.hpp (props changed)
branches/release/boost/uuid/ (props changed)
branches/release/boost/variant/ (props changed)
branches/release/boost/version.hpp (props changed)
branches/release/boost/wave/ (props changed)
branches/release/bootstrap.bat (props changed)
branches/release/bootstrap.sh (props changed)
branches/release/doc/ (props changed)
branches/release/index.htm (props changed)
branches/release/index.html (props changed)
branches/release/libs/ (props changed)
branches/release/libs/array/doc/array.xml (props changed)
branches/release/libs/array/test/array0.cpp (props changed)
branches/release/libs/bimap/ (props changed)
branches/release/libs/config/ (props changed)
branches/release/libs/filesystem/ (props changed)
branches/release/libs/functional/hash/ (props changed)
branches/release/libs/fusion/ (props changed)
branches/release/libs/graph_parallel/ (props changed)
branches/release/libs/integer/ (props changed)
branches/release/libs/interprocess/ (props changed)
branches/release/libs/intrusive/ (props changed)
branches/release/libs/iostreams/ (props changed)
branches/release/libs/libraries.htm (props changed)
branches/release/libs/maintainers.txt (props changed)
branches/release/libs/math/ (props changed)
branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
branches/release/libs/numeric/ublas/ (props changed)
branches/release/libs/numeric/ublas/doc/ (props changed)
branches/release/libs/program_options/ (props changed)
branches/release/libs/property_tree/ (props changed)
branches/release/libs/python/ (props changed)
branches/release/libs/range/ (props changed)
branches/release/libs/range/doc/ (props changed)
branches/release/libs/regex/ (props changed)
branches/release/libs/regex/doc/ (props changed)
branches/release/libs/serialization/ (props changed)
branches/release/libs/signals/ (props changed)
branches/release/libs/signals2/ (props changed)
branches/release/libs/spirit/ (props changed)
branches/release/libs/spirit/classic/example/ (props changed)
branches/release/libs/spirit/doc/ (props changed)
branches/release/libs/spirit/example/ (props changed)
branches/release/libs/spirit/phoenix/ (props changed)
branches/release/libs/spirit/test/ (props changed)
branches/release/libs/spirit/test/qi/optional.cpp (props changed)
branches/release/libs/statechart/ (props changed)
branches/release/libs/static_assert/ (props changed)
branches/release/libs/system/ (props changed)
branches/release/libs/thread/ (props changed)
branches/release/libs/timer/ (props changed)
branches/release/libs/tr1/ (props changed)
branches/release/libs/type_traits/ (props changed)
branches/release/libs/unordered/ (props changed)
branches/release/libs/utility/ (props changed)
branches/release/libs/utility/swap.html (props changed)
branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
branches/release/libs/utility/value_init.htm (props changed)
branches/release/libs/utility/value_init_test.cpp (props changed)
branches/release/libs/uuid/ (props changed)
branches/release/libs/wave/ (props changed)
branches/release/more/ (props changed)
branches/release/more/getting_started/ (props changed)
branches/release/people/ (props changed)
branches/release/rst.css (props changed)
branches/release/status/ (props changed)
branches/release/status/Jamfile.v2 (props changed)
branches/release/tools/ (props changed)
branches/release/tools/bcp/ (props changed)
branches/release/tools/boostbook/ (props changed)
branches/release/tools/build/v2/ (props changed)
branches/release/tools/build/v2/tools/ (props changed)
branches/release/tools/inspect/ (props changed)
branches/release/tools/jam/ (props changed)
branches/release/tools/quickbook/ (props changed)
branches/release/tools/regression/ (props changed)
branches/release/tools/release/ (props changed)
branches/release/tools/wave/ (props changed)
branches/release/wiki/ (props changed)
Text files modified:
branches/release/boost/proto/args.hpp | 54 +-
branches/release/boost/proto/debug.hpp | 69 +-
branches/release/boost/proto/deep_copy.hpp | 29
branches/release/boost/proto/detail/expr0.hpp | 126 +++++
branches/release/boost/proto/domain.hpp | 314 ++++++++------
branches/release/boost/proto/expr.hpp | 18
branches/release/boost/proto/extends.hpp | 99 ++--
branches/release/boost/proto/fusion.hpp | 6
branches/release/boost/proto/generate.hpp | 509 ++++++++++++----------
branches/release/boost/proto/literal.hpp | 2
branches/release/boost/proto/make_expr.hpp | 241 ++--------
branches/release/boost/proto/matches.hpp | 894 +++++++++++++++++++--------------------
branches/release/boost/proto/operators.hpp | 47 +
branches/release/boost/proto/proto_fwd.hpp | 299 +++++-------
branches/release/boost/proto/proto_typeof.hpp | 45 +
branches/release/boost/proto/traits.hpp | 840 +++++++++++++++++++------------------
branches/release/boost/proto/transform/arg.hpp | 4
branches/release/boost/proto/transform/call.hpp | 12
branches/release/boost/proto/transform/make.hpp | 60 ++
branches/release/boost/proto/transform/pass_through.hpp | 18
branches/release/boost/proto/transform/when.hpp | 14
branches/release/libs/proto/doc/glossary.qbk | 6
branches/release/libs/proto/doc/proto.qbk | 2
branches/release/libs/proto/doc/reference.xml | 20
branches/release/libs/proto/doc/reference/args.xml | 23
branches/release/libs/proto/doc/reference/concepts/Domain.xml | 13
branches/release/libs/proto/doc/reference/concepts/Expr.xml | 22
branches/release/libs/proto/doc/reference/domain.xml | 63 ++
branches/release/libs/proto/doc/reference/expr.xml | 140 ++++++
branches/release/libs/proto/doc/reference/extends.xml | 3
branches/release/libs/proto/doc/reference/make_expr.xml | 16
branches/release/libs/proto/doc/reference/matches.xml | 32
branches/release/libs/proto/doc/reference/traits.xml | 210 ++++----
branches/release/libs/proto/doc/reference/transform/pass_through.xml | 2
branches/release/libs/proto/doc/reference/transform/when.xml | 8
branches/release/libs/proto/test/make_expr.cpp | 169 ++++++-
branches/release/libs/proto/test/proto_fusion_s.cpp | 18
37 files changed, 2461 insertions(+), 1986 deletions(-)
Modified: branches/release/boost/proto/args.hpp
==============================================================================
--- branches/release/boost/proto/args.hpp (original)
+++ branches/release/boost/proto/args.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -120,42 +120,38 @@
}
////////////////////////////////////////////////////////////////////////////////////////////
- namespace argsns_
+ #define BOOST_PROTO_DEFINE_CHILD_N(Z, N, DATA) \
+ typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(child, N); \
+ /**< INTERNAL ONLY */
+
+ #define BOOST_PROTO_DEFINE_VOID_N(z, n, data) \
+ typedef mpl::void_ BOOST_PP_CAT(child, n); \
+ /**< INTERNAL ONLY */
+
+ /// \brief A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
+ ///
+ /// A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
+ /// The types in the sequence correspond to the children of a node in an expression tree.
+ template< typename Arg0 >
+ struct term
{
+ BOOST_STATIC_CONSTANT(long, arity = 0);
+ typedef Arg0 child0;
- #define BOOST_PROTO_DEFINE_CHILD_N(Z, N, DATA) \
- typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(child, N); \
- /**< INTERNAL ONLY */
-
- #define BOOST_PROTO_DEFINE_VOID_N(z, n, data) \
- typedef mpl::void_ BOOST_PP_CAT(child, n); \
- /**< INTERNAL ONLY */
+ #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_DEFINE_VOID_N, ~)
+ #endif
- /// \brief A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
+ /// INTERNAL ONLY
///
- /// A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
- /// The types in the sequence correspond to the children of a node in an expression tree.
- template< typename Arg0 >
- struct term
- {
- BOOST_STATIC_CONSTANT(long, arity = 0);
- typedef Arg0 child0;
-
- #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_DEFINE_VOID_N, ~)
- #endif
-
- /// INTERNAL ONLY
- ///
- typedef Arg0 back_;
- };
+ typedef Arg0 back_;
+ };
- #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/args.hpp>))
- #include BOOST_PP_ITERATE()
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/args.hpp>))
+ #include BOOST_PP_ITERATE()
- #undef BOOST_PROTO_DEFINE_CHILD_N
+ #undef BOOST_PROTO_DEFINE_CHILD_N
- }
////////////////////////////////////////////////////////////////////////////////////////////
}}
#endif
Modified: branches/release/boost/proto/debug.hpp
==============================================================================
--- branches/release/boost/proto/debug.hpp (original)
+++ branches/release/boost/proto/debug.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -9,18 +9,16 @@
#ifndef BOOST_PROTO_DEBUG_HPP_EAN_12_31_2006
#define BOOST_PROTO_DEBUG_HPP_EAN_12_31_2006
-#include <boost/preprocessor/iteration/local.hpp>
-#include <boost/preprocessor/repetition/repeat.hpp>
-#include <boost/preprocessor/stringize.hpp>
#include <iomanip>
#include <iostream>
#include <typeinfo>
+#include <boost/preprocessor/stringize.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/proto/proto_fwd.hpp>
-#include <boost/proto/expr.hpp>
#include <boost/proto/traits.hpp>
#include <boost/proto/matches.hpp>
-#include <boost/proto/detail/dont_care.hpp>
+#include <boost/proto/fusion.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
namespace boost { namespace proto
{
@@ -111,6 +109,8 @@
/// purposes.
struct display_expr
{
+ BOOST_PROTO_CALLABLE()
+
typedef void result_type;
/// \param sout The \c ostream to which the expression tree
@@ -126,48 +126,39 @@
/// \brief Pretty-print the current node in a Proto expression
/// tree.
- template<typename Tag, typename Args>
- void operator()(proto::expr<Tag, Args, 0> const &expr) const
+ template<typename Expr>
+ void operator()(Expr const &expr) const
+ {
+ this->impl(expr, mpl::long_<arity_of<Expr>::value>());
+ }
+
+ private:
+ display_expr(display_expr const &);
+ display_expr &operator =(display_expr const &);
+
+ template<typename Expr>
+ void impl(Expr const &expr, mpl::long_<0>) const
{
using namespace hidden_detail_;
- this->sout_ << std::setw(this->depth_) << (this->first_? "" : ", ")
- << Tag() << "(" << proto::value(expr) << ")\n";
+ typedef typename tag_of<Expr>::type tag;
+ this->sout_ << std::setw(this->depth_) << (this->first_? "" : ", ");
+ this->sout_ << tag() << "(" << proto::value(expr) << ")\n";
this->first_ = false;
}
- #define BOOST_PROTO_CHILD(Z, N, DATA) \
- display(proto::child_c<N>(expr)); \
- /**/
-
- #define BOOST_PP_LOCAL_MACRO(N) \
- /** \overload */ \
- template<typename Tag, typename Args> \
- void operator()(proto::expr<Tag, Args, N> const &expr) const \
- { \
- using namespace hidden_detail_; \
- this->sout_ << std::setw(this->depth_) << (this->first_? "" : ", ") \
- << Tag() << "(\n"; \
- display_expr display(this->sout_, this->depth_ + 4); \
- BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, _) \
- this->sout_ << std::setw(this->depth_) << "" << ")\n"; \
- this->first_ = false; \
- } \
- /**/
-
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_PROTO_MAX_ARITY)
- #include BOOST_PP_LOCAL_ITERATE()
- #undef BOOST_PROTO_CHILD
-
- /// \overload
- ///
- template<typename T>
- void operator()(T const &t) const
+ template<typename Expr, typename Arity>
+ void impl(Expr const &expr, Arity) const
{
- (*this)(t.proto_base());
+ using namespace hidden_detail_;
+ typedef typename tag_of<Expr>::type tag;
+ this->sout_ << std::setw(this->depth_) << (this->first_? "" : ", ");
+ this->sout_ << tag() << "(\n";
+ display_expr display(this->sout_, this->depth_ + 4);
+ fusion::for_each(expr, display);
+ this->sout_ << std::setw(this->depth_) << "" << ")\n";
+ this->first_ = false;
}
- private:
- display_expr &operator =(display_expr const &);
int depth_;
mutable bool first_;
std::ostream &sout_;
Modified: branches/release/boost/proto/deep_copy.hpp
==============================================================================
--- branches/release/boost/proto/deep_copy.hpp (original)
+++ branches/release/boost/proto/deep_copy.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -40,14 +40,21 @@
>::type
actual_terminal_type;
- typedef typename terminal<actual_terminal_type>::type expr_type;
+ typedef
+ typename base_expr<
+ typename Expr::proto_domain
+ , tag::terminal
+ , term<actual_terminal_type>
+ >::type
+ expr_;
+
typedef typename Expr::proto_generator proto_generator;
- typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
+ typedef typename proto_generator::template result<proto_generator(expr_)>::type result_type;
template<typename Expr2, typename S, typename D>
result_type operator()(Expr2 const &e, S const &, D const &) const
{
- return proto_generator()(expr_type::make(e.proto_base().child0));
+ return proto_generator()(expr_::make(e.proto_base().child0));
}
};
}
@@ -161,7 +168,7 @@
#define BOOST_PROTO_DEFINE_DEEP_COPY_TYPE(Z, N, DATA) \
typename deep_copy_impl< \
typename remove_reference< \
- typename Expr::BOOST_PP_CAT(proto_child, N) \
+ typename Expr::BOOST_PP_CAT(proto_child, N) \
>::type::proto_derived_expr \
>::result_type \
/**/
@@ -189,22 +196,22 @@
struct deep_copy_impl<Expr, N>
{
typedef
- proto::expr<
- typename Expr::proto_tag
+ typename base_expr<
+ typename Expr::proto_domain
+ , typename Expr::proto_tag
, BOOST_PP_CAT(list, N)<
BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_DEEP_COPY_TYPE, ~)
>
- , N
- >
- expr_type;
+ >::type
+ expr_;
typedef typename Expr::proto_generator proto_generator;
- typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
+ typedef typename proto_generator::template result<proto_generator(expr_)>::type result_type;
template<typename Expr2, typename S, typename D>
result_type operator()(Expr2 const &e, S const &, D const &) const
{
- expr_type const that = {
+ expr_ const that = {
BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_DEEP_COPY_FUN, ~)
};
Modified: branches/release/boost/proto/detail/expr0.hpp
==============================================================================
--- branches/release/boost/proto/detail/expr0.hpp (original)
+++ branches/release/boost/proto/detail/expr0.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -12,6 +12,127 @@
#define ARG_COUNT BOOST_PP_MAX(1, BOOST_PP_ITERATION())
+ /// \brief Simplified representation of a node in an expression tree.
+ ///
+ /// \c proto::basic_expr\<\> is a node in an expression template tree. It
+ /// is a container for its child sub-trees. It also serves as
+ /// the terminal nodes of the tree.
+ ///
+ /// \c Tag is type that represents the operation encoded by
+ /// this expression. It is typically one of the structs
+ /// in the \c boost::proto::tag namespace, but it doesn't
+ /// have to be.
+ ///
+ /// \c Args is a type list representing the type of the children
+ /// of this expression. It is an instantiation of one
+ /// of \c proto::list1\<\>, \c proto::list2\<\>, etc. The
+ /// child types must all themselves be either \c expr\<\>
+ /// or <tt>proto::expr\<\>&</tt>. If \c Args is an
+ /// instantiation of \c proto::term\<\> then this
+ /// \c expr\<\> type represents a terminal expression;
+ /// the parameter to the \c proto::term\<\> template
+ /// represents the terminal's value type.
+ ///
+ /// \c Arity is an integral constant representing the number of child
+ /// nodes this node contains. If \c Arity is 0, then this
+ /// node is a terminal.
+ ///
+ /// \c proto::basic_expr\<\> is a valid Fusion random-access sequence, where
+ /// the elements of the sequence are the child expressions.
+ #ifdef BOOST_PROTO_DEFINE_TERMINAL
+ template<typename Tag, typename Arg0>
+ struct basic_expr<Tag, term<Arg0>, 0>
+ #else
+ template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(ARG_COUNT, typename Arg)>
+ struct basic_expr<Tag, BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)>, BOOST_PP_ITERATION() >
+ #endif
+ {
+ typedef Tag proto_tag;
+ BOOST_STATIC_CONSTANT(long, proto_arity_c = BOOST_PP_ITERATION());
+ typedef mpl::long_<BOOST_PP_ITERATION() > proto_arity;
+ typedef basic_expr proto_base_expr;
+ #ifdef BOOST_PROTO_DEFINE_TERMINAL
+ typedef term<Arg0> proto_args;
+ #else
+ typedef BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)> proto_args;
+ #endif
+ typedef basic_expr proto_grammar;
+ typedef default_domain proto_domain;
+ typedef default_generator proto_generator;
+ typedef proto::tag::proto_expr fusion_tag;
+ typedef basic_expr proto_derived_expr;
+ typedef void proto_is_expr_; /**< INTERNAL ONLY */
+
+ BOOST_PP_REPEAT(ARG_COUNT, BOOST_PROTO_CHILD, ~)
+ BOOST_PP_REPEAT_FROM_TO(ARG_COUNT, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)
+
+ /// \return *this
+ ///
+ basic_expr const &proto_base() const
+ {
+ return *this;
+ }
+
+ /// \overload
+ ///
+ basic_expr &proto_base()
+ {
+ return *this;
+ }
+
+ #ifdef BOOST_PROTO_DEFINE_TERMINAL
+ /// \return A new \c expr\<\> object initialized with the specified
+ /// arguments.
+ ///
+ template<typename A0>
+ static basic_expr const make(A0 &a0)
+ {
+ return detail::make_terminal(a0, static_cast<basic_expr *>(0), static_cast<proto_args *>(0));
+ }
+
+ /// \overload
+ ///
+ template<typename A0>
+ static basic_expr const make(A0 const &a0)
+ {
+ return detail::make_terminal(a0, static_cast<basic_expr *>(0), static_cast<proto_args *>(0));
+ }
+ #else
+ /// \return A new \c expr\<\> object initialized with the specified
+ /// arguments.
+ ///
+ template<BOOST_PP_ENUM_PARAMS(ARG_COUNT, typename A)>
+ static basic_expr const make(BOOST_PP_ENUM_BINARY_PARAMS(ARG_COUNT, A, const &a))
+ {
+ basic_expr that = {BOOST_PP_ENUM_PARAMS(ARG_COUNT, a)};
+ return that;
+ }
+ #endif
+
+ #if 1 == BOOST_PP_ITERATION()
+ /// If \c Tag is \c boost::proto::tag::address_of and \c proto_child0 is
+ /// <tt>T&</tt>, then \c address_of_hack_type_ is <tt>T*</tt>.
+ /// Otherwise, it is some undefined type.
+ typedef typename detail::address_of_hack<Tag, proto_child0>::type address_of_hack_type_;
+
+ /// \return The address of <tt>this->child0</tt> if \c Tag is
+ /// \c boost::proto::tag::address_of. Otherwise, this function will
+ /// fail to compile.
+ ///
+ /// \attention Proto overloads <tt>operator&</tt>, which means that
+ /// proto-ified objects cannot have their addresses taken, unless we use
+ /// the following hack to make \c &x implicitly convertible to \c X*.
+ operator address_of_hack_type_() const
+ {
+ return boost::addressof(this->child0);
+ }
+ #else
+ /// INTERNAL ONLY
+ ///
+ typedef detail::not_a_valid_type address_of_hack_type_;
+ #endif
+ };
+
/// \brief Representation of a node in an expression tree.
///
/// \c proto::expr\<\> is a node in an expression template tree. It
@@ -56,6 +177,7 @@
#else
typedef BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)> proto_args;
#endif
+ typedef basic_expr<Tag, proto_args, BOOST_PP_ITERATION() > proto_grammar;
typedef default_domain proto_domain;
typedef default_generator proto_generator;
typedef proto::tag::proto_expr fusion_tag;
@@ -86,7 +208,7 @@
template<typename A0>
static expr const make(A0 &a0)
{
- return detail::make_terminal(a0, static_cast<expr *>(0));
+ return detail::make_terminal(a0, static_cast<expr *>(0), static_cast<proto_args *>(0));
}
/// \overload
@@ -94,7 +216,7 @@
template<typename A0>
static expr const make(A0 const &a0)
{
- return detail::make_terminal(a0, static_cast<expr *>(0));
+ return detail::make_terminal(a0, static_cast<expr *>(0), static_cast<proto_args *>(0));
}
#else
/// \return A new \c expr\<\> object initialized with the specified
Modified: branches/release/boost/proto/domain.hpp
==============================================================================
--- branches/release/boost/proto/domain.hpp (original)
+++ branches/release/boost/proto/domain.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -11,9 +11,8 @@
#ifndef BOOST_PROTO_DOMAIN_HPP_EAN_02_13_2007
#define BOOST_PROTO_DOMAIN_HPP_EAN_02_13_2007
-#include <boost/config.hpp>
#include <boost/ref.hpp>
-#include <boost/proto/generate.hpp>
+#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/detail/deduce_domain.hpp>
namespace boost { namespace proto
@@ -31,149 +30,194 @@
{};
}
- namespace domainns_
+ /// \brief For use in defining domain tags to be used
+ /// with \c proto::extends\<\>. A \e Domain associates
+ /// an expression type with a \e Generator, and optionally
+ /// a \e Grammar.
+ ///
+ /// The Generator determines how new expressions in the
+ /// domain are constructed. Typically, a generator wraps
+ /// all new expressions in a wrapper that imparts
+ /// domain-specific behaviors to expressions within its
+ /// domain. (See \c proto::extends\<\>.)
+ ///
+ /// The Grammar determines whether a given expression is
+ /// valid within the domain, and automatically disables
+ /// any operator overloads which would cause an invalid
+ /// expression to be created. By default, the Grammar
+ /// parameter defaults to the wildcard, \c proto::_, which
+ /// makes all expressions valid within the domain.
+ ///
+ /// The Super declares the domain currently being defined
+ /// to be a sub-domain of Super. Expressions in sub-domains
+ /// can be freely combined with expressions in its super-
+ /// domain (and <I>its</I> super-domain, etc.).
+ ///
+ /// Example:
+ /// \code
+ /// template<typename Expr>
+ /// struct MyExpr;
+ ///
+ /// struct MyGrammar
+ /// : or_< terminal<_>, plus<MyGrammar, MyGrammar> >
+ /// {};
+ ///
+ /// // Define MyDomain, in which all expressions are
+ /// // wrapped in MyExpr<> and only expressions that
+ /// // conform to MyGrammar are allowed.
+ /// struct MyDomain
+ /// : domain<generator<MyExpr>, MyGrammar>
+ /// {};
+ ///
+ /// // Use MyDomain to define MyExpr
+ /// template<typename Expr>
+ /// struct MyExpr
+ /// : extends<Expr, MyExpr<Expr>, MyDomain>
+ /// {
+ /// // ...
+ /// };
+ /// \endcode
+ ///
+ template<
+ typename Generator // = default_generator
+ , typename Grammar // = proto::_
+ , typename Super // = detail::not_a_domain
+ >
+ struct domain
+ : Generator
{
- /// \brief For use in defining domain tags to be used
- /// with \c proto::extends\<\>. A \e Domain associates
- /// an expression type with a \e Generator, and optionally
- /// a \e Grammar.
- ///
- /// The Generator determines how new expressions in the
- /// domain are constructed. Typically, a generator wraps
- /// all new expressions in a wrapper that imparts
- /// domain-specific behaviors to expressions within its
- /// domain. (See \c proto::extends\<\>.)
- ///
- /// The Grammar determines whether a given expression is
- /// valid within the domain, and automatically disables
- /// any operator overloads which would cause an invalid
- /// expression to be created. By default, the Grammar
- /// parameter defaults to the wildcard, \c proto::_, which
- /// makes all expressions valid within the domain.
- ///
- /// Example:
- /// \code
- /// template<typename Expr>
- /// struct MyExpr;
- ///
- /// struct MyGrammar
- /// : or_< terminal<_>, plus<MyGrammar, MyGrammar> >
- /// {};
- ///
- /// // Define MyDomain, in which all expressions are
- /// // wrapped in MyExpr<> and only expressions that
- /// // conform to MyGrammar are allowed.
- /// struct MyDomain
- /// : domain<generator<MyExpr>, MyGrammar>
- /// {};
- ///
- /// // Use MyDomain to define MyExpr
- /// template<typename Expr>
- /// struct MyExpr
- /// : extends<Expr, MyExpr<Expr>, MyDomain>
- /// {
- /// // ...
- /// };
- /// \endcode
- ///
- template<
- typename Generator // = default_generator
- , typename Grammar // = proto::_
- , typename Super // = detail::not_a_domain
- >
- struct domain
- : Generator
- {
- typedef Generator proto_generator;
- typedef Grammar proto_grammar;
- typedef Super proto_super_domain;
-
- /// INTERNAL ONLY
- typedef void proto_is_domain_;
- };
-
- /// \brief The domain expressions have by default, if
- /// \c proto::extends\<\> has not been used to associate
- /// a domain with an expression.
- ///
- struct default_domain
- : domain<>
- {};
+ typedef Generator proto_generator;
+ typedef Grammar proto_grammar;
+ typedef Super proto_super_domain;
- /// \brief A pseudo-domain for use in functions and
- /// metafunctions that require a domain parameter. It
- /// indicates that the domain of the parent node should
- /// be inferred from the domains of the child nodes.
- ///
- /// \attention \c deduce_domain is not itself a valid domain.
- ///
- struct deduce_domain
- : domain<detail::not_a_generator, detail::not_a_grammar, detail::not_a_domain>
- {};
- }
+ /// INTERNAL ONLY
+ typedef void proto_is_domain_;
+ };
- namespace result_of
+ /// \brief The domain expressions have by default, if
+ /// \c proto::extends\<\> has not been used to associate
+ /// a domain with an expression.
+ ///
+ struct default_domain
+ : domain<>
+ {};
+
+ /// \brief A pseudo-domain for use in functions and
+ /// metafunctions that require a domain parameter. It
+ /// indicates that the domain of the parent node should
+ /// be inferred from the domains of the child nodes.
+ ///
+ /// \attention \c deduce_domain is not itself a valid domain.
+ ///
+ struct deduce_domain
+ : domain<detail::not_a_generator, detail::not_a_grammar, detail::not_a_domain>
+ {};
+
+ /// A metafunction that returns \c mpl::true_
+ /// if the type \c T is the type of a Proto domain;
+ /// \c mpl::false_ otherwise. If \c T inherits from
+ /// \c proto::domain\<\>, \c is_domain\<T\> is
+ /// \c mpl::true_.
+ template<typename T, typename Void /* = void*/>
+ struct is_domain
+ : mpl::false_
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<typename T>
+ struct is_domain<T, typename T::proto_is_domain_>
+ : mpl::true_
+ {};
+
+ /// A metafunction that returns the domain of
+ /// a given type. If \c T is a Proto expression
+ /// type, it returns that expression's associated
+ /// domain. If not, it returns
+ /// \c proto::default_domain.
+ template<typename T, typename Void /* = void*/>
+ struct domain_of
{
- /// A metafunction that returns \c mpl::true_
- /// if the type \c T is the type of a Proto domain;
- /// \c mpl::false_ otherwise. If \c T inherits from
- /// \c proto::domain\<\>, \c is_domain\<T\> is
- /// \c mpl::true_.
- template<typename T, typename Void /* = void*/>
- struct is_domain
- : mpl::false_
- {};
+ typedef default_domain type;
+ };
- /// INTERNAL ONLY
- ///
- template<typename T>
- struct is_domain<T, typename T::proto_is_domain_>
- : mpl::true_
- {};
+ /// INTERNAL ONLY
+ ///
+ template<typename T>
+ struct domain_of<T, typename T::proto_is_expr_>
+ {
+ typedef typename T::proto_domain type;
+ };
- /// A metafunction that returns the domain of
- /// a given type. If \c T is a Proto expression
- /// type, it returns that expression's associated
- /// domain. If not, it returns
- /// \c proto::default_domain.
- template<typename T, typename Void /* = void*/>
- struct domain_of
- {
- typedef default_domain type;
- };
+ /// INTERNAL ONLY
+ ///
+ template<typename T>
+ struct domain_of<T &, void>
+ {
+ typedef typename domain_of<T>::type type;
+ };
- /// INTERNAL ONLY
- ///
- template<typename T>
- struct domain_of<T, typename T::proto_is_expr_>
- {
- typedef typename T::proto_domain type;
- };
+ /// INTERNAL ONLY
+ ///
+ template<typename T>
+ struct domain_of<boost::reference_wrapper<T>, void>
+ {
+ typedef typename domain_of<T>::type type;
+ };
- /// INTERNAL ONLY
- ///
- template<typename T>
- struct domain_of<T &, void>
- {
- typedef typename domain_of<T>::type type;
- };
+ /// INTERNAL ONLY
+ ///
+ template<typename T>
+ struct domain_of<boost::reference_wrapper<T> const, void>
+ {
+ typedef typename domain_of<T>::type type;
+ };
- /// INTERNAL ONLY
- ///
- template<typename T>
- struct domain_of<boost::reference_wrapper<T>, void>
- {
- typedef typename domain_of<T>::type type;
- };
+ /// \brief Tests a domain to see whether its generator would prefer
+ /// to be passed instances of \c proto::basic_expr\<\> rather than
+ /// \c proto::expr\<\>.
+ ///
+ template<typename Domain, typename Void>
+ struct wants_basic_expr
+ : mpl::false_
+ {};
+
+ template<typename Domain>
+ struct wants_basic_expr<Domain, typename Domain::proto_use_basic_expr_>
+ : mpl::true_
+ {};
+
+ /// \brief Given a domain, a tag type and an argument list,
+ /// compute the type of the expression to generate. This is
+ /// either an instance of \c proto::expr\<\> or
+ /// \c proto::basic_expr\<\>.
+ ///
+ template<typename Domain, typename Tag, typename Args, typename Void>
+ struct base_expr
+ {
+ typedef proto::expr<Tag, Args, Args::arity> type;
+ };
+
+ /// INTERNAL ONLY
+ ///
+ template<typename Domain, typename Tag, typename Args>
+ struct base_expr<Domain, Tag, Args, typename Domain::proto_use_basic_expr_>
+ {
+ typedef proto::basic_expr<Tag, Args, Args::arity> type;
+ };
+
+ /// \brief Annotate a domain to indicate that its generator would
+ /// prefer to be passed instances of \c proto::basic_expr\<\> rather
+ /// than \c proto::expr\<\>. <tt>use_basic_expr\<Domain\></tt> is
+ /// itself a domain.
+ ///
+ template<typename Domain>
+ struct use_basic_expr
+ : Domain
+ {
+ BOOST_PROTO_USE_BASIC_EXPR()
+ };
- /// INTERNAL ONLY
- ///
- template<typename T>
- struct domain_of<boost::reference_wrapper<T> const, void>
- {
- typedef typename domain_of<T>::type type;
- };
- }
}}
#endif
Modified: branches/release/boost/proto/expr.hpp
==============================================================================
--- branches/release/boost/proto/expr.hpp (original)
+++ branches/release/boost/proto/expr.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -69,17 +69,17 @@
typedef Expr *type;
};
- template<typename T, typename Tag, typename Arg0>
- proto::expr<Tag, proto::term<Arg0>, 0> make_terminal(T &t, proto::expr<Tag, proto::term<Arg0>, 0> *)
+ template<typename T, typename Expr, typename Arg0>
+ Expr make_terminal(T &t, Expr *, proto::term<Arg0> *)
{
- proto::expr<Tag, proto::term<Arg0>, 0> that = {t};
+ Expr that = {t};
return that;
}
- template<typename T, typename Tag, typename Arg0, std::size_t N>
- proto::expr<Tag, proto::term<Arg0[N]>, 0> make_terminal(T (&t)[N], proto::expr<Tag, proto::term<Arg0[N]>, 0> *)
+ template<typename T, typename Expr, typename Arg0, std::size_t N>
+ Expr make_terminal(T (&t)[N], Expr *, proto::term<Arg0[N]> *)
{
- expr<Tag, proto::term<Arg0[N]>, 0> that;
+ Expr that;
for(std::size_t i = 0; i < N; ++i)
{
that.child0[i] = t[i];
@@ -87,10 +87,10 @@
return that;
}
- template<typename T, typename Tag, typename Arg0, std::size_t N>
- proto::expr<Tag, proto::term<Arg0[N]>, 0> make_terminal(T const(&t)[N], proto::expr<Tag, proto::term<Arg0[N]>, 0> *)
+ template<typename T, typename Expr, typename Arg0, std::size_t N>
+ Expr make_terminal(T const(&t)[N], Expr *, proto::term<Arg0[N]> *)
{
- expr<Tag, proto::term<Arg0[N]>, 0> that;
+ Expr that;
for(std::size_t i = 0; i < N; ++i)
{
that.child0[i] = t[i];
Modified: branches/release/boost/proto/extends.hpp
==============================================================================
--- branches/release/boost/proto/extends.hpp (original)
+++ branches/release/boost/proto/extends.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -165,6 +165,7 @@
typedef typename proto_base_expr::proto_tag proto_tag; \
typedef typename proto_base_expr::proto_args proto_args; \
typedef typename proto_base_expr::proto_arity proto_arity; \
+ typedef typename proto_base_expr::proto_grammar proto_grammar; \
typedef typename proto_base_expr::address_of_hack_type_ proto_address_of_hack_type_; \
typedef void proto_is_expr_; /**< INTERNAL ONLY */ \
BOOST_STATIC_CONSTANT(long, proto_arity_c = proto_base_expr::proto_arity_c); \
@@ -203,31 +204,33 @@
BOOST_PROTO_DISABLE_MSVC_C4522 \
Typename() boost::tr1_result_of< \
Typename() This::proto_generator( \
- boost::proto::expr< \
- boost::proto::tag::assign \
+ Typename() boost::proto::base_expr< \
+ Typename() This::proto_domain \
+ , boost::proto::tag::assign \
, boost::proto::list2< \
This & \
, This Const() & \
> \
- , 2 \
- > \
+ >::type \
) \
>::type const \
operator =(This Const() &a) \
{ \
- typedef boost::proto::expr< \
- boost::proto::tag::assign \
- , boost::proto::list2< \
- This & \
- , This Const() & \
- > \
- , 2 \
- > that_type; \
+ typedef \
+ Typename() boost::proto::base_expr< \
+ Typename() This::proto_domain \
+ , boost::proto::tag::assign \
+ , boost::proto::list2< \
+ This & \
+ , This Const() & \
+ > \
+ >::type \
+ that_type; \
that_type const that = { \
*this \
, a \
}; \
- return Typename() This::proto_generator()(that); \
+ return Typename() This::proto_generator()(that); \
} \
/**/
@@ -250,26 +253,28 @@
template<typename A> \
typename boost::tr1_result_of< \
proto_generator( \
- boost::proto::expr< \
- boost::proto::tag::assign \
+ typename boost::proto::base_expr< \
+ proto_domain \
+ , boost::proto::tag::assign \
, boost::proto::list2< \
proto_derived_expr ThisConst() & \
, typename boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
> \
- , 2 \
- > \
+ >::type \
) \
>::type const \
operator =(A ThatConst() &a) ThisConst() \
{ \
- typedef boost::proto::expr< \
- boost::proto::tag::assign \
- , boost::proto::list2< \
- proto_derived_expr ThisConst() & \
- , typename boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
- > \
- , 2 \
- > that_type; \
+ typedef \
+ typename boost::proto::base_expr< \
+ proto_domain \
+ , boost::proto::tag::assign \
+ , boost::proto::list2< \
+ proto_derived_expr ThisConst() & \
+ , typename boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
+ > \
+ >::type \
+ that_type; \
that_type const that = { \
*static_cast<proto_derived_expr ThisConst() *>(this) \
, boost::proto::as_child<proto_domain>(a) \
@@ -314,26 +319,28 @@
template<typename A> \
typename boost::tr1_result_of< \
proto_generator( \
- boost::proto::expr< \
- boost::proto::tag::subscript \
+ typename boost::proto::base_expr< \
+ proto_domain \
+ , boost::proto::tag::subscript \
, boost::proto::list2< \
proto_derived_expr ThisConst() & \
, typename boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
> \
- , 2 \
- > \
+ >::type \
) \
>::type const \
operator [](A ThatConst() &a) ThisConst() \
{ \
- typedef boost::proto::expr< \
- boost::proto::tag::subscript \
- , boost::proto::list2< \
- proto_derived_expr ThisConst() & \
- , typename boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
- > \
- , 2 \
- > that_type; \
+ typedef \
+ typename boost::proto::base_expr< \
+ proto_domain \
+ , boost::proto::tag::subscript \
+ , boost::proto::list2< \
+ proto_derived_expr ThisConst() & \
+ , typename boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
+ > \
+ >::type \
+ that_type; \
that_type const that = { \
*static_cast<proto_derived_expr ThisConst() *>(this) \
, boost::proto::as_child<proto_domain>(a) \
@@ -576,20 +583,20 @@
template<typename This, typename Fun, typename Domain>
struct virtual_member
{
- typedef
- expr<tag::member, list2<This &, expr<tag::terminal, term<Fun> > const &>, 2>
- proto_base_expr;
typedef Domain proto_domain;
typedef typename Domain::proto_generator proto_generator;
typedef virtual_member<This, Fun, Domain> proto_derived_expr;
- typedef typename proto_base_expr::proto_tag proto_tag;
- typedef typename proto_base_expr::proto_args proto_args;
- typedef typename proto_base_expr::proto_arity proto_arity;
- typedef typename proto_base_expr::address_of_hack_type_ proto_address_of_hack_type_;
+ typedef tag::member proto_tag;
+ typedef list2<This &, expr<tag::terminal, term<Fun> > const &> proto_args;
+ typedef mpl::long_<2> proto_arity;
+ typedef detail::not_a_valid_type proto_address_of_hack_type_;
typedef void proto_is_expr_; /**< INTERNAL ONLY */
- BOOST_STATIC_CONSTANT(long, proto_arity_c = proto_base_expr::proto_arity_c);
+ BOOST_STATIC_CONSTANT(long, proto_arity_c = 2);
typedef boost::proto::tag::proto_expr fusion_tag;
- BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_EXTENDS_CHILD, ~)
+ typedef This &proto_child0;
+ typedef expr<tag::terminal, term<Fun> > const &proto_child1;
+ typedef expr<proto_tag, proto_args, proto_arity_c> proto_base_expr;
+ typedef basic_expr<proto_tag, proto_args, proto_arity_c> proto_grammar;
typedef void proto_is_aggregate_; /**< INTERNAL ONLY */
BOOST_PROTO_EXTENDS_ASSIGN_()
Modified: branches/release/boost/proto/fusion.hpp
==============================================================================
--- branches/release/boost/proto/fusion.hpp (original)
+++ branches/release/boost/proto/fusion.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -728,6 +728,12 @@
{
typedef fusion::fusion_sequence_tag type;
};
+
+ template<typename Tag, typename Args, long Arity>
+ struct sequence_tag< proto::basic_expr<Tag, Args, Arity> >
+ {
+ typedef fusion::fusion_sequence_tag type;
+ };
}}
#if BOOST_MSVC
Modified: branches/release/boost/proto/generate.hpp
==============================================================================
--- branches/release/boost/proto/generate.hpp (original)
+++ branches/release/boost/proto/generate.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -12,11 +12,14 @@
#define BOOST_PROTO_GENERATE_HPP_EAN_02_13_2007
#include <boost/config.hpp>
- #include <boost/utility/result_of.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
- #include <boost/preprocessor/repetition/enum.hpp>
+ #include <boost/preprocessor/facilities/intercept.hpp>
+ #include <boost/preprocessor/repetition/enum_params.hpp>
+ #include <boost/preprocessor/repetition/enum_binary_params.hpp>
+ #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/utility/enable_if.hpp>
+ #include <boost/utility/result_of.hpp>
#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/args.hpp>
@@ -26,39 +29,38 @@
namespace detail
{
template<typename Expr>
- struct expr_params;
+ struct by_value_generator_;
- template<typename Tag, typename Args, long N>
- struct expr_params<proto::expr<Tag, Args, N> >
+ template<typename Tag, typename Arg>
+ struct by_value_generator_<proto::expr<Tag, term<Arg>, 0> >
{
- typedef Tag tag;
- typedef Args args;
- BOOST_STATIC_CONSTANT(long, arity = N);
- };
-
- template<typename Expr, long Arity = expr_params<Expr>::arity>
- struct by_value_generator_;
+ typedef
+ proto::expr<
+ Tag
+ , term<typename detail::term_traits<Arg>::value_type>
+ , 0
+ >
+ type;
- #define BOOST_PROTO_DEFINE_BY_VALUE_TYPE(Z, N, Expr) \
- typename uncvref<typename expr_params<Expr>::args::BOOST_PP_CAT(child, N)>::type \
- /**/
-
- #define BOOST_PROTO_DEFINE_BY_VALUE(Z, N, expr) \
- expr.BOOST_PP_CAT(child, N) \
- /**/
+ static type const call(proto::expr<Tag, term<Arg>, 0> const &e)
+ {
+ type that = {e.child0};
+ return that;
+ }
+ };
- template<typename Expr>
- struct by_value_generator_<Expr, 0>
+ template<typename Tag, typename Arg>
+ struct by_value_generator_<proto::basic_expr<Tag, term<Arg>, 0> >
{
typedef
- proto::expr<
- typename expr_params<Expr>::tag
- , term<typename detail::term_traits<typename expr_params<Expr>::args::child0>::value_type>
+ proto::basic_expr<
+ Tag
+ , term<typename detail::term_traits<Arg>::value_type>
, 0
>
type;
- static type const make(Expr const &e)
+ static type const call(proto::basic_expr<Tag, term<Arg>, 0> const &e)
{
type that = {e.child0};
return that;
@@ -73,241 +75,240 @@
}
- namespace generatorns_
+ /// \brief A simple generator that passes an expression
+ /// through unchanged.
+ ///
+ /// Generators are intended for use as the first template parameter
+ /// to the \c domain\<\> class template and control if and how
+ /// expressions within that domain are to be customized.
+ /// The \c default_generator makes no modifications to the expressions
+ /// passed to it.
+ struct default_generator
{
- /// \brief A simple generator that passes an expression
- /// through unchanged.
- ///
- /// Generators are intended for use as the first template parameter
- /// to the \c domain\<\> class template and control if and how
- /// expressions within that domain are to be customized.
- /// The \c default_generator makes no modifications to the expressions
- /// passed to it.
- struct default_generator
- {
- BOOST_PROTO_CALLABLE()
+ BOOST_PROTO_CALLABLE()
- template<typename Sig>
- struct result;
+ template<typename Sig>
+ struct result;
- template<typename This, typename Expr>
- struct result<This(Expr)>
- {
- typedef Expr type;
- };
-
- /// \param expr A Proto expression
- /// \return expr
- template<typename Expr>
- #ifdef BOOST_PROTO_STRICT_RESULT_OF
- Expr
- #else
- Expr const &
- #endif
- operator ()(Expr const &e) const
- {
- return e;
- }
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ {
+ typedef Expr type;
};
- /// \brief A generator that wraps expressions passed
- /// to it in the specified extension wrapper.
- ///
- /// Generators are intended for use as the first template parameter
- /// to the \c domain\<\> class template and control if and how
- /// expressions within that domain are to be customized.
- /// \c generator\<\> wraps each expression passed to it in
- /// the \c Extends\<\> wrapper.
- template<template<typename> class Extends>
- struct generator
+ /// \param expr A Proto expression
+ /// \return expr
+ template<typename Expr>
+ #ifdef BOOST_PROTO_STRICT_RESULT_OF
+ Expr
+ #else
+ Expr const &
+ #endif
+ operator ()(Expr const &e) const
{
- BOOST_PROTO_CALLABLE()
+ return e;
+ }
+ };
- template<typename Sig>
- struct result;
+ /// \brief A generator that wraps expressions passed
+ /// to it in the specified extension wrapper.
+ ///
+ /// Generators are intended for use as the first template parameter
+ /// to the \c domain\<\> class template and control if and how
+ /// expressions within that domain are to be customized.
+ /// \c generator\<\> wraps each expression passed to it in
+ /// the \c Extends\<\> wrapper.
+ template<template<typename> class Extends>
+ struct generator
+ {
+ BOOST_PROTO_CALLABLE()
+ BOOST_PROTO_USE_BASIC_EXPR()
- template<typename This, typename Expr>
- struct result<This(Expr)>
- {
- typedef Extends<Expr> type;
- };
+ template<typename Sig>
+ struct result;
- template<typename This, typename Expr>
- struct result<This(Expr &)>
- {
- typedef Extends<Expr> type;
- };
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ {
+ typedef Extends<Expr> type;
+ };
- template<typename This, typename Expr>
- struct result<This(Expr const &)>
- {
- typedef Extends<Expr> type;
- };
+ template<typename This, typename Expr>
+ struct result<This(Expr &)>
+ {
+ typedef Extends<Expr> type;
+ };
- /// \param expr A Proto expression
- /// \return Extends<Expr>(expr)
- template<typename Expr>
- Extends<Expr> operator ()(Expr const &e) const
- {
- return Extends<Expr>(e);
- }
+ template<typename This, typename Expr>
+ struct result<This(Expr const &)>
+ {
+ typedef Extends<Expr> type;
};
- /// \brief A generator that wraps expressions passed
- /// to it in the specified extension wrapper and uses
- /// aggregate initialization for the wrapper.
- ///
- /// Generators are intended for use as the first template parameter
- /// to the \c domain\<\> class template and control if and how
- /// expressions within that domain are to be customized.
- /// \c pod_generator\<\> wraps each expression passed to it in
- /// the \c Extends\<\> wrapper, and uses aggregate initialzation
- /// for the wrapped object.
- template<template<typename> class Extends>
- struct pod_generator
+ /// \param expr A Proto expression
+ /// \return Extends<Expr>(expr)
+ template<typename Expr>
+ Extends<Expr> operator ()(Expr const &e) const
{
- BOOST_PROTO_CALLABLE()
+ return Extends<Expr>(e);
+ }
+ };
- template<typename Sig>
- struct result;
+ /// \brief A generator that wraps expressions passed
+ /// to it in the specified extension wrapper and uses
+ /// aggregate initialization for the wrapper.
+ ///
+ /// Generators are intended for use as the first template parameter
+ /// to the \c domain\<\> class template and control if and how
+ /// expressions within that domain are to be customized.
+ /// \c pod_generator\<\> wraps each expression passed to it in
+ /// the \c Extends\<\> wrapper, and uses aggregate initialzation
+ /// for the wrapped object.
+ template<template<typename> class Extends>
+ struct pod_generator
+ {
+ BOOST_PROTO_CALLABLE()
+ BOOST_PROTO_USE_BASIC_EXPR()
- template<typename This, typename Expr>
- struct result<This(Expr)>
- {
- typedef Extends<Expr> type;
- };
+ template<typename Sig>
+ struct result;
- template<typename This, typename Expr>
- struct result<This(Expr &)>
- {
- typedef Extends<Expr> type;
- };
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ {
+ typedef Extends<Expr> type;
+ };
- template<typename This, typename Expr>
- struct result<This(Expr const &)>
- {
- typedef Extends<Expr> type;
- };
+ template<typename This, typename Expr>
+ struct result<This(Expr &)>
+ {
+ typedef Extends<Expr> type;
+ };
- /// \param expr The expression to wrap
- /// \return <tt>Extends\<Expr\> that = {expr}; return that;</tt>
- template<typename Expr>
- Extends<Expr> operator ()(Expr const &e) const
- {
- Extends<Expr> that = {e};
- return that;
- }
+ template<typename This, typename Expr>
+ struct result<This(Expr const &)>
+ {
+ typedef Extends<Expr> type;
};
- /// \brief A generator that replaces child nodes held by
- /// reference with ones held by value. Use with
- /// \c compose_generators to forward that result to another
- /// generator.
- ///
- /// Generators are intended for use as the first template parameter
- /// to the \c domain\<\> class template and control if and how
- /// expressions within that domain are to be customized.
- /// \c by_value_generator ensures all child nodes are
- /// held by value. This generator is typically composed with a
- /// second generator for further processing, as
- /// <tt>compose_generators\<by_value_generator, MyGenerator\></tt>.
- struct by_value_generator
+ /// \param expr The expression to wrap
+ /// \return <tt>Extends\<Expr\> that = {expr}; return that;</tt>
+ template<typename Expr>
+ Extends<Expr> operator ()(Expr const &e) const
{
- BOOST_PROTO_CALLABLE()
+ Extends<Expr> that = {e};
+ return that;
+ }
+ };
- template<typename Sig>
- struct result;
+ /// \brief A generator that replaces child nodes held by
+ /// reference with ones held by value. Use with
+ /// \c compose_generators to forward that result to another
+ /// generator.
+ ///
+ /// Generators are intended for use as the first template parameter
+ /// to the \c domain\<\> class template and control if and how
+ /// expressions within that domain are to be customized.
+ /// \c by_value_generator ensures all child nodes are
+ /// held by value. This generator is typically composed with a
+ /// second generator for further processing, as
+ /// <tt>compose_generators\<by_value_generator, MyGenerator\></tt>.
+ struct by_value_generator
+ {
+ BOOST_PROTO_CALLABLE()
- template<typename This, typename Expr>
- struct result<This(Expr)>
- {
- typedef
- typename detail::by_value_generator_<Expr>::type
- type;
- };
+ template<typename Sig>
+ struct result;
- template<typename This, typename Expr>
- struct result<This(Expr &)>
- {
- typedef
- typename detail::by_value_generator_<Expr>::type
- type;
- };
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ {
+ typedef
+ typename detail::by_value_generator_<Expr>::type
+ type;
+ };
- template<typename This, typename Expr>
- struct result<This(Expr const &)>
- {
- typedef
- typename detail::by_value_generator_<Expr>::type
- type;
- };
-
- /// \param expr The expression to modify.
- /// \return <tt>deep_copy(expr)</tt>
- template<typename Expr>
- typename result<by_value_generator(Expr)>::type operator ()(Expr const &e) const
- {
- return detail::by_value_generator_<Expr>::make(e);
- }
+ template<typename This, typename Expr>
+ struct result<This(Expr &)>
+ {
+ typedef
+ typename detail::by_value_generator_<Expr>::type
+ type;
};
- /// \brief A composite generator that first applies one
- /// transform to an expression and then forwards the result
- /// on to another generator for further transformation.
- ///
- /// Generators are intended for use as the first template parameter
- /// to the \c domain\<\> class template and control if and how
- /// expressions within that domain are to be customized.
- /// \c compose_generators\<\> is a composite generator that first
- /// applies one transform to an expression and then forwards the
- /// result on to another generator for further transformation.
- template<typename First, typename Second>
- struct compose_generators
+ template<typename This, typename Expr>
+ struct result<This(Expr const &)>
{
- BOOST_PROTO_CALLABLE()
+ typedef
+ typename detail::by_value_generator_<Expr>::type
+ type;
+ };
- template<typename Sig>
- struct result;
+ /// \param expr The expression to modify.
+ /// \return <tt>deep_copy(expr)</tt>
+ template<typename Expr>
+ typename result<by_value_generator(Expr)>::type operator ()(Expr const &e) const
+ {
+ return detail::by_value_generator_<Expr>::call(e);
+ }
+ };
- template<typename This, typename Expr>
- struct result<This(Expr)>
- {
- typedef
- typename Second::template result<
- Second(typename First::template result<First(Expr)>::type)
- >::type
- type;
- };
+ /// \brief A composite generator that first applies one
+ /// transform to an expression and then forwards the result
+ /// on to another generator for further transformation.
+ ///
+ /// Generators are intended for use as the first template parameter
+ /// to the \c domain\<\> class template and control if and how
+ /// expressions within that domain are to be customized.
+ /// \c compose_generators\<\> is a composite generator that first
+ /// applies one transform to an expression and then forwards the
+ /// result on to another generator for further transformation.
+ template<typename First, typename Second>
+ struct compose_generators
+ {
+ BOOST_PROTO_CALLABLE()
- template<typename This, typename Expr>
- struct result<This(Expr &)>
- {
- typedef
- typename Second::template result<
- Second(typename First::template result<First(Expr)>::type)
- >::type
- type;
- };
+ template<typename Sig>
+ struct result;
- template<typename This, typename Expr>
- struct result<This(Expr const &)>
- {
- typedef
- typename Second::template result<
- Second(typename First::template result<First(Expr)>::type)
- >::type
- type;
- };
-
- /// \param expr The expression to modify.
- /// \return Second()(First()(expr))
- template<typename Expr>
- typename result<compose_generators(Expr)>::type operator ()(Expr const &e) const
- {
- return Second()(First()(e));
- }
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ {
+ typedef
+ typename Second::template result<
+ Second(typename First::template result<First(Expr)>::type)
+ >::type
+ type;
+ };
+
+ template<typename This, typename Expr>
+ struct result<This(Expr &)>
+ {
+ typedef
+ typename Second::template result<
+ Second(typename First::template result<First(Expr)>::type)
+ >::type
+ type;
};
- }
+
+ template<typename This, typename Expr>
+ struct result<This(Expr const &)>
+ {
+ typedef
+ typename Second::template result<
+ Second(typename First::template result<First(Expr)>::type)
+ >::type
+ type;
+ };
+
+ /// \param expr The expression to modify.
+ /// \return Second()(First()(expr))
+ template<typename Expr>
+ typename result<compose_generators(Expr)>::type operator ()(Expr const &e) const
+ {
+ return Second()(First()(e));
+ }
+ };
/// INTERNAL ONLY
template<>
@@ -363,25 +364,55 @@
#define N BOOST_PP_ITERATION()
- template<typename Expr>
- struct by_value_generator_<Expr, N>
+ template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Arg) >
+ struct by_value_generator_<
+ proto::expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, Arg)>, N>
+ >
{
typedef
- proto::expr<
- typename expr_params<Expr>::tag
- , BOOST_PP_CAT(list, N)<
- // typename uncvref<typename expr_params<Expr>::args::child0>::type, ...
- BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_BY_VALUE_TYPE, Expr)
- >
- , N
+ BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, Arg)>
+ src_args;
+
+ typedef
+ BOOST_PP_CAT(list, N)<
+ BOOST_PP_ENUM_BINARY_PARAMS(N, typename uncvref<Arg, >::type BOOST_PP_INTERCEPT)
>
- type;
+ dst_args;
+
+ typedef proto::expr<Tag, src_args, N> src_type;
+ typedef proto::expr<Tag, dst_args, N> type;
+
+ static type const call(src_type const &e)
+ {
+ type that = {
+ BOOST_PP_ENUM_PARAMS(N, e.child)
+ };
+ return that;
+ }
+ };
+
+ template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Arg) >
+ struct by_value_generator_<
+ proto::basic_expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, Arg)>, N>
+ >
+ {
+ typedef
+ BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, Arg)>
+ src_args;
+
+ typedef
+ BOOST_PP_CAT(list, N)<
+ BOOST_PP_ENUM_BINARY_PARAMS(N, typename uncvref<Arg, >::type BOOST_PP_INTERCEPT)
+ >
+ dst_args;
+
+ typedef proto::basic_expr<Tag, src_args, N> src_type;
+ typedef proto::basic_expr<Tag, dst_args, N> type;
- static type const make(Expr const &e)
+ static type const call(src_type const &e)
{
type that = {
- // expr.child0, ...
- BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_BY_VALUE, e)
+ BOOST_PP_ENUM_PARAMS(N, e.child)
};
return that;
}
Modified: branches/release/boost/proto/literal.hpp
==============================================================================
--- branches/release/boost/proto/literal.hpp (original)
+++ branches/release/boost/proto/literal.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -25,7 +25,7 @@
///
/// A simple wrapper for a terminal, provided for
/// ease of use. In all cases, <tt>literal\<X\> l(x);</tt>
- /// is equivalent to <tt>terminal\<X\>::::type l = {x};</tt>.
+ /// is equivalent to <tt>terminal\<X\>::type l = {x};</tt>.
///
/// The \c Domain template parameter defaults to
/// \c proto::default_domain.
Modified: branches/release/boost/proto/make_expr.hpp
==============================================================================
--- branches/release/boost/proto/make_expr.hpp (original)
+++ branches/release/boost/proto/make_expr.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -155,41 +155,23 @@
{
template<typename T, typename Domain>
struct protoify_
- {
- typedef
- typename boost::unwrap_reference<T>::type
- unref_type;
-
- typedef
- typename mpl::eval_if_c<
- boost::is_reference_wrapper<T>::value
- , proto::result_of::as_child<unref_type, Domain>
- , proto::result_of::as_expr<unref_type, Domain>
- >::type
- type;
-
- static type call(T &t)
- {
- return typename mpl::if_c<
- is_reference_wrapper<T>::value
- , functional::as_child<Domain>
- , functional::as_expr<Domain>
- >::type()(static_cast<unref_type &>(t));
- }
- };
+ : result_of::as_expr<T, Domain>
+ {};
template<typename T, typename Domain>
struct protoify_<T &, Domain>
- {
- typedef
- typename proto::result_of::as_child<T, Domain>::type
- type;
+ : result_of::as_child<T, Domain>
+ {};
- static type call(T &t)
- {
- return functional::as_child<Domain>()(t);
- }
- };
+ template<typename T, typename Domain>
+ struct protoify_<boost::reference_wrapper<T>, Domain>
+ : result_of::as_child<T, Domain>
+ {};
+
+ template<typename T, typename Domain>
+ struct protoify_<boost::reference_wrapper<T> const, Domain>
+ : result_of::as_child<T, Domain>
+ {};
template<typename Tag, typename Domain, typename Sequence, std::size_t Size>
struct unpack_expr_
@@ -255,73 +237,6 @@
: make_expr_<tag::terminal, default_domain, A>
{};
- template<typename Base, typename Expr>
- Expr implicit_expr_wrap(Base const &e, mpl::false_, Expr *)
- {
- return Expr(e);
- }
-
- template<typename Base, typename Expr>
- Expr implicit_expr_wrap(Base const &e, mpl::true_, Expr *)
- {
- Expr that = {e};
- return that;
- }
-
- template<typename A0, typename Void = void>
- struct implicit_expr_1
- {
- A0 &a0;
-
- template<typename Args>
- operator proto::expr<tag::terminal, Args, 0>() const
- {
- proto::expr<tag::terminal, Args, 0> that = {this->a0};
- return that;
- }
-
- template<typename Expr>
- operator Expr() const
- {
- typename Expr::proto_base_expr that = *this;
- return detail::implicit_expr_wrap(that, is_aggregate<Expr>(), static_cast<Expr *>(0));
- }
- };
-
- template<typename A0>
- struct implicit_expr_1<A0, typename A0::proto_is_expr_>
- {
- A0 &a0;
-
- #if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, BOOST_TESTED_AT(1010))
- typedef typename remove_cv<A0>::type uncv_a0_type;
-
- operator uncv_a0_type &() const
- {
- return const_cast<uncv_a0_type &>(this->a0);
- }
- #else
- operator A0 &() const
- {
- return this->a0;
- }
- #endif
-
- template<typename Tag, typename Args>
- operator proto::expr<Tag, Args, 1>() const
- {
- proto::expr<Tag, Args, 1> that = {this->a0};
- return that;
- }
-
- template<typename Expr>
- operator Expr() const
- {
- typename Expr::proto_base_expr that = *this;
- return detail::implicit_expr_wrap(that, is_aggregate<Expr>(), static_cast<Expr *>(0));
- }
- };
-
#define BOOST_PP_ITERATION_PARAMS_1 \
(4, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/make_expr.hpp>, 1)) \
/**/
@@ -340,7 +255,7 @@
///
/// In this specialization, the domain is deduced from the
/// domains of the child types. (If
- /// <tt>is_domain\<A0\>::::value</tt> is \c true, then another
+ /// <tt>is_domain\<A0\>::value</tt> is \c true, then another
/// specialization is selected.)
template<
typename Tag
@@ -350,12 +265,12 @@
>
struct make_expr
{
- /// Same as <tt>result_of::make_expr\<Tag, D, A0, ... AN\>::::type</tt>
+ /// Same as <tt>result_of::make_expr\<Tag, D, A0, ... AN\>::type</tt>
/// where \c D is the deduced domain, which is calculated as follows:
///
/// For each \c x in <tt>[0,N)</tt> (proceeding in order beginning with
- /// <tt>x=0</tt>), if <tt>domain_of\<Ax\>::::type</tt> is not
- /// \c default_domain, then \c D is <tt>domain_of\<Ax\>::::type</tt>.
+ /// <tt>x=0</tt>), if <tt>domain_of\<Ax\>::type</tt> is not
+ /// \c default_domain, then \c D is <tt>domain_of\<Ax\>::type</tt>.
/// Otherwise, \c D is \c default_domain.
typedef
typename detail::make_expr_<
@@ -385,26 +300,26 @@
{
/// If \c Tag is <tt>tag::terminal</tt>, then \c type is a
/// typedef for <tt>boost::result_of\<Domain(expr\<tag::terminal,
- /// term\<A0\> \>)\>::::type</tt>.
+ /// term\<A0\> \>)\>::type</tt>.
///
/// Otherwise, \c type is a typedef for <tt>boost::result_of\<Domain(expr\<Tag,
- /// listN\< as_child\<A0\>::::type, ... as_child\<AN\>::::type\>)
- /// \>::::type</tt>, where \c N is the number of non-void template
- /// arguments, and <tt>as_child\<A\>::::type</tt> is evaluated as
+ /// listN\< as_child\<A0\>::type, ... as_child\<AN\>::type\>)
+ /// \>::type</tt>, where \c N is the number of non-void template
+ /// arguments, and <tt>as_child\<A\>::type</tt> is evaluated as
/// follows:
///
- /// \li If <tt>is_expr\<A\>::::value</tt> is \c true, then the
+ /// \li If <tt>is_expr\<A\>::value</tt> is \c true, then the
/// child type is \c A.
/// \li If \c A is <tt>B &</tt> or <tt>cv boost::reference_wrapper\<B\></tt>,
- /// and <tt>is_expr\<B\>::::value</tt> is \c true, then the
+ /// and <tt>is_expr\<B\>::value</tt> is \c true, then the
/// child type is <tt>B &</tt>.
- /// \li If <tt>is_expr\<A\>::::value</tt> is \c false, then the
+ /// \li If <tt>is_expr\<A\>::value</tt> is \c false, then the
/// child type is <tt>boost::result_of\<Domain(expr\<tag::terminal, term\<A\> \>
- /// )\>::::type</tt>.
+ /// )\>::type</tt>.
/// \li If \c A is <tt>B &</tt> or <tt>cv boost::reference_wrapper\<B\></tt>,
- /// and <tt>is_expr\<B\>::::value</tt> is \c false, then the
+ /// and <tt>is_expr\<B\>::value</tt> is \c false, then the
/// child type is <tt>boost::result_of\<Domain(expr\<tag::terminal, term\<B &\> \>
- /// )\>::::type</tt>.
+ /// )\>::type</tt>.
typedef
typename detail::make_expr_<
Tag
@@ -425,7 +340,7 @@
///
/// In this specialization, the domain is deduced from the
/// domains of the child types. (If
- /// <tt>is_domain\<Sequence>::::value</tt> is \c true, then another
+ /// <tt>is_domain\<Sequence>::value</tt> is \c true, then another
/// specialization is selected.)
template<
typename Tag
@@ -438,8 +353,8 @@
/// Let \c S be the type of a Fusion Random Access Sequence
/// equivalent to \c Sequence. Then \c type is the
/// same as <tt>result_of::make_expr\<Tag,
- /// fusion::result_of::value_at_c\<S, 0\>::::type, ...
- /// fusion::result_of::value_at_c\<S, N-1\>::::type\>::::type</tt>,
+ /// fusion::result_of::value_at_c\<S, 0\>::type, ...
+ /// fusion::result_of::value_at_c\<S, N-1\>::type\>::type</tt>,
/// where \c N is the size of \c S.
typedef
typename detail::unpack_expr_<
@@ -462,8 +377,8 @@
/// Let \c S be the type of a Fusion Random Access Sequence
/// equivalent to \c Sequence. Then \c type is the
/// same as <tt>result_of::make_expr\<Tag, Domain,
- /// fusion::result_of::value_at_c\<S, 0\>::::type, ...
- /// fusion::result_of::value_at_c\<S, N-1\>::::type\>::::type</tt>,
+ /// fusion::result_of::value_at_c\<S, 0\>::type, ...
+ /// fusion::result_of::value_at_c\<S, N-1\>::type\>::type</tt>,
/// where \c N is the size of \c S.
typedef
typename detail::unpack_expr_<
@@ -662,7 +577,7 @@
/// <tt>as_expr\<Domain\>(x)</tt>.
///
/// Let <tt>make_\<Tag\>(b0,...bN)</tt> be defined as
- /// <tt>expr\<Tag, listN\<C0,...CN\> \>::::make(c0,...cN)</tt>
+ /// <tt>expr\<Tag, listN\<C0,...CN\> \>::make(c0,...cN)</tt>
/// where \c Bx is the type of \c bx.
///
/// \return <tt>Domain()(make_\<Tag\>(wrap_(a0),...wrap_(aN)))</tt>.
@@ -722,14 +637,14 @@
/// Let \c s be a Fusion Random Access Sequence equivalent to \c sequence.
/// Let <tt>wrap_\<N\>(s)</tt>, where \c s has type \c S, be defined
/// such that:
- /// \li If <tt>fusion::result_of::value_at_c\<S,N\>::::type</tt> is a reference,
+ /// \li If <tt>fusion::result_of::value_at_c\<S,N\>::type</tt> is a reference,
/// <tt>wrap_\<N\>(s)</tt> is equivalent to
/// <tt>as_child\<Domain\>(fusion::at_c\<N\>(s))</tt>.
/// \li Otherwise, <tt>wrap_\<N\>(s)</tt> is equivalent to
/// <tt>as_expr\<Domain\>(fusion::at_c\<N\>(s))</tt>.
///
/// Let <tt>make_\<Tag\>(b0,...bN)</tt> be defined as
- /// <tt>expr\<Tag, listN\<B0,...BN\> \>::::make(b0,...bN)</tt>
+ /// <tt>expr\<Tag, listN\<B0,...BN\> \>::make(b0,...bN)</tt>
/// where \c Bx is the type of \c bx.
///
/// \param sequence a Fusion Forward Sequence.
@@ -764,24 +679,6 @@
>::call(sequence2);
}
- /// \brief Return a proxy object that holds its arguments by reference
- /// and is implicitly convertible to an expression.
- template<typename A0>
- detail::implicit_expr_1<A0> const
- implicit_expr(A0 &a0)
- {
- detail::implicit_expr_1<A0> that = {a0};
- return that;
- }
-
- // Additional overloads generated by the preprocessor...
-
- #define BOOST_PP_ITERATION_PARAMS_1 \
- (4, (2, BOOST_PROTO_MAX_ARITY, <boost/proto/make_expr.hpp>, 4)) \
- /**/
-
- #include BOOST_PP_ITERATE()
-
/// INTERNAL ONLY
///
template<typename Tag, typename Domain>
@@ -825,47 +722,17 @@
#define N BOOST_PP_ITERATION()
#define M BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N)
- #if N > 1
- template<BOOST_PP_ENUM_PARAMS(N, typename A)>
- struct BOOST_PP_CAT(implicit_expr_, N)
- {
- #define M0(Z, N, DATA) BOOST_PP_CAT(A, N) &BOOST_PP_CAT(a, N);
- BOOST_PP_REPEAT(N, M0, ~)
- #undef M0
-
- template<typename Tag, typename Args>
- operator proto::expr<Tag, Args, N>() const
- {
- #define M0(Z, N, DATA) \
- implicit_expr_1<BOOST_PP_CAT(A, N)> BOOST_PP_CAT(b, N) \
- = {this->BOOST_PP_CAT(a, N)}; \
- typename Args::BOOST_PP_CAT(child, N) BOOST_PP_CAT(c, N) = BOOST_PP_CAT(b, N); \
- /**/
- BOOST_PP_REPEAT(N, M0, ~)
- #undef M0
- proto::expr<Tag, Args, N> that = {BOOST_PP_ENUM_PARAMS(N, c)};
- return that;
- }
-
- template<typename Expr>
- operator Expr() const
- {
- typename Expr::proto_base_expr that = *this;
- return detail::implicit_expr_wrap(that, is_aggregate<Expr>(), static_cast<Expr *>(0));
- }
- };
- #endif
-
template<typename Tag, typename Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
struct make_expr_<Tag, Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
BOOST_PP_ENUM_TRAILING_PARAMS(M, void BOOST_PP_INTERCEPT), void>
{
- typedef proto::expr<
- Tag
- , BOOST_PP_CAT(list, N)<BOOST_PP_ENUM(N, BOOST_PROTO_AS_CHILD_TYPE, (A, ~, Domain)) >
- , N
- > expr_type;
+ typedef
+ BOOST_PP_CAT(list, N)<
+ BOOST_PP_ENUM(N, BOOST_PROTO_AS_CHILD_TYPE, (A, ~, Domain))
+ >
+ proto_args;
+ typedef typename base_expr<Domain, Tag, proto_args>::type expr_type;
typedef typename Domain::proto_generator proto_generator;
typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
@@ -893,14 +760,13 @@
{
BOOST_PROTO_FUSION_ITERATORS_TYPE(N)
- typedef proto::expr<
- Tag
- , BOOST_PP_CAT(list, N)<
+ typedef
+ BOOST_PP_CAT(list, N)<
BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE, ~)
>
- , N
- > expr_type;
+ proto_args;
+ typedef typename base_expr<Domain, Tag, proto_args>::type expr_type;
typedef typename Domain::proto_generator proto_generator;
typedef typename proto_generator::template result<proto_generator(expr_type)>::type type;
@@ -1018,21 +884,4 @@
#undef N
-#elif BOOST_PP_ITERATION_FLAGS() == 4
-
- #define N BOOST_PP_ITERATION()
-
- /// \overload
- ///
- template<BOOST_PP_ENUM_PARAMS(N, typename A)>
- detail::BOOST_PP_CAT(implicit_expr_, N)<BOOST_PP_ENUM_PARAMS(N, A)> const
- implicit_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a))
- {
- detail::BOOST_PP_CAT(implicit_expr_, N)<BOOST_PP_ENUM_PARAMS(N, A)> that
- = {BOOST_PP_ENUM_PARAMS(N, a)};
- return that;
- }
-
- #undef N
-
#endif // BOOST_PP_IS_ITERATING
Modified: branches/release/boost/proto/matches.hpp
==============================================================================
--- branches/release/boost/proto/matches.hpp (original)
+++ branches/release/boost/proto/matches.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -140,14 +140,20 @@
template<typename Args1, typename Args2, typename Back>
struct vararg_matches<Args1, Args2, Back, true, true, typename Back::proto_is_vararg_>
- : matches_<proto::expr<ignore, Args1, Args1::arity>, proto::expr<ignore, Args2, Args1::arity> >
+ : matches_<
+ proto::basic_expr<ignore, Args1, Args1::arity>
+ , proto::basic_expr<ignore, Args2, Args1::arity>
+ >
{};
template<typename Args1, typename Args2, typename Back>
struct vararg_matches<Args1, Args2, Back, true, false, typename Back::proto_is_vararg_>
: and_2<
- matches_<proto::expr<ignore, Args1, Args2::arity>, proto::expr<ignore, Args2, Args2::arity> >::value
- , vararg_matches_impl<Args1, typename Back::proto_base_expr, Args2::arity + 1, Args1::arity>
+ matches_<
+ proto::basic_expr<ignore, Args1, Args2::arity>
+ , proto::basic_expr<ignore, Args2, Args2::arity>
+ >::value
+ , vararg_matches_impl<Args1, typename Back::proto_grammar, Args2::arity + 1, Args1::arity>
>
{};
@@ -297,56 +303,56 @@
{};
template<typename Tag, typename Args1, long N1, typename Args2, long N2>
- struct matches_< proto::expr<Tag, Args1, N1>, proto::expr<Tag, Args2, N2> >
+ struct matches_< proto::basic_expr<Tag, Args1, N1>, proto::basic_expr<Tag, Args2, N2> >
: vararg_matches< Args1, Args2, typename Args2::back_, (N1+2 > N2), (N2 > N1) >
{};
template<typename Tag, typename Args1, long N1, typename Args2, long N2>
- struct matches_< proto::expr<Tag, Args1, N1>, proto::expr<proto::_, Args2, N2> >
+ struct matches_< proto::basic_expr<Tag, Args1, N1>, proto::basic_expr<proto::_, Args2, N2> >
: vararg_matches< Args1, Args2, typename Args2::back_, (N1+2 > N2), (N2 > N1) >
{};
template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::expr<Tag, Args1, 0>, proto::expr<Tag, Args2, 0> >
+ struct matches_< proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<Tag, Args2, 0> >
: terminal_matches<typename Args1::child0, typename Args2::child0>
{};
template<typename Tag, typename Args1, typename Args2, long N2>
- struct matches_< proto::expr<Tag, Args1, 0>, proto::expr<proto::_, Args2, N2> >
+ struct matches_< proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<proto::_, Args2, N2> >
: mpl::false_
{};
template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::expr<Tag, Args1, 0>, proto::expr<proto::_, Args2, 0> >
+ struct matches_< proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<proto::_, Args2, 0> >
: terminal_matches<typename Args1::child0, typename Args2::child0>
{};
template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::expr<Tag, Args1, 1>, proto::expr<Tag, Args2, 1> >
+ struct matches_< proto::basic_expr<Tag, Args1, 1>, proto::basic_expr<Tag, Args2, 1> >
: matches_<
- typename detail::expr_traits<typename Args1::child0>::value_type::proto_base_expr
- , typename Args2::child0::proto_base_expr
+ typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar
+ , typename Args2::child0::proto_grammar
>
{};
template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::expr<Tag, Args1, 1>, proto::expr<proto::_, Args2, 1> >
+ struct matches_< proto::basic_expr<Tag, Args1, 1>, proto::basic_expr<proto::_, Args2, 1> >
: matches_<
- typename detail::expr_traits<typename Args1::child0>::value_type::proto_base_expr
- , typename Args2::child0::proto_base_expr
+ typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar
+ , typename Args2::child0::proto_grammar
>
{};
#define BOOST_PROTO_MATCHES_N_FUN(Z, N, DATA) \
matches_< \
- typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_base_expr\
- , typename Args2::BOOST_PP_CAT(child, N)::proto_base_expr \
+ typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_grammar\
+ , typename Args2::BOOST_PP_CAT(child, N)::proto_grammar \
>
#define BOOST_PROTO_DEFINE_MATCHES(Z, N, DATA) \
matches_< \
- typename Expr::proto_base_expr \
- , typename BOOST_PP_CAT(G, N)::proto_base_expr \
+ Expr \
+ , typename BOOST_PP_CAT(G, N)::proto_grammar \
>
#define BOOST_PROTO_DEFINE_LAMBDA_MATCHES(Z, N, DATA) \
@@ -370,21 +376,23 @@
#undef BOOST_PROTO_DEFINE_LAMBDA_MATCHES
// handle proto::if_
- template<typename Expr, typename If, typename Then, typename Else>
- struct matches_<Expr, proto::if_<If, Then, Else> >
+ template<typename Tag, typename Args, long Arity, typename If, typename Then, typename Else>
+ struct matches_<proto::basic_expr<Tag, Args, Arity>, proto::if_<If, Then, Else> >
: mpl::eval_if_c<
remove_reference<
- typename when<_, If>::template impl<Expr, int, int>::result_type
+ typename when<_, If>::
+ template impl<proto::expr<Tag, Args, Arity>, int, int>::result_type
>::type::value
- , matches_<Expr, typename Then::proto_base_expr>
- , matches_<Expr, typename Else::proto_base_expr>
+ , matches_<proto::basic_expr<Tag, Args, Arity>, typename Then::proto_grammar>
+ , matches_<proto::basic_expr<Tag, Args, Arity>, typename Else::proto_grammar>
>::type
{};
- template<typename Expr, typename If>
- struct matches_<Expr, proto::if_<If> >
+ template<typename Tag, typename Args, long Arity, typename If>
+ struct matches_<proto::basic_expr<Tag, Args, Arity>, proto::if_<If> >
: detail::uncvref<
- typename when<_, If>::template impl<Expr, int, int>::result_type
+ typename when<_, If>::
+ template impl<proto::expr<Tag, Args, Arity>, int, int>::result_type
>::type
{};
@@ -398,7 +406,7 @@
template<typename Expr, typename G0>
struct matches_<Expr, or_<G0> >
- : matches_<Expr, typename G0::proto_base_expr>
+ : matches_<Expr, typename G0::proto_grammar>
{
typedef G0 which;
};
@@ -411,179 +419,172 @@
template<typename Expr, typename G0>
struct matches_<Expr, and_<G0> >
- : matches_<Expr, typename G0::proto_base_expr>
+ : matches_<Expr, typename G0::proto_grammar>
{};
// handle proto::not_
template<typename Expr, typename Grammar>
struct matches_<Expr, not_<Grammar> >
- : mpl::not_<matches_<Expr, typename Grammar::proto_base_expr> >
+ : mpl::not_<matches_<Expr, typename Grammar::proto_grammar> >
{};
// handle proto::switch_
- template<typename Expr, typename Cases>
- struct matches_<Expr, switch_<Cases> >
+ template<typename Tag, typename Args, long Arity, typename Cases>
+ struct matches_<proto::basic_expr<Tag, Args, Arity>, switch_<Cases> >
: matches_<
- Expr
- , typename Cases::template case_<typename Expr::proto_tag>::proto_base_expr
+ proto::basic_expr<Tag, Args, Arity>
+ , typename Cases::template case_<Tag>::proto_grammar
>
{};
}
- namespace result_of
- {
- /// \brief A Boolean metafunction that evaluates whether a given
- /// expression type matches a grammar.
- ///
- /// <tt>matches\<Expr,Grammar\></tt> inherits (indirectly) from
- /// \c mpl::true_ if <tt>Expr::proto_base_expr</tt> matches
- /// <tt>Grammar::proto_base_expr</tt>, and from \c mpl::false_
- /// otherwise.
- ///
- /// Non-terminal expressions are matched against a grammar
- /// according to the following rules:
- ///
- /// \li The wildcard pattern, \c _, matches any expression.
- /// \li An expression <tt>expr\<AT, listN\<A0,A1,...An\> \></tt>
- /// matches a grammar <tt>expr\<BT, listN\<B0,B1,...Bn\> \></tt>
- /// if \c BT is \c _ or \c AT, and if \c Ax matches \c Bx for
- /// each \c x in <tt>[0,n)</tt>.
- /// \li An expression <tt>expr\<AT, listN\<A0,...An,U0,...Um\> \></tt>
- /// matches a grammar <tt>expr\<BT, listM\<B0,...Bn,vararg\<V\> \> \></tt>
- /// if \c BT is \c _ or \c AT, and if \c Ax matches \c Bx
- /// for each \c x in <tt>[0,n)</tt> and if \c Ux matches \c V
- /// for each \c x in <tt>[0,m)</tt>.
- /// \li An expression \c E matches <tt>or_\<B0,B1,...Bn\></tt> if \c E
- /// matches some \c Bx for \c x in <tt>[0,n)</tt>.
- /// \li An expression \c E matches <tt>and_\<B0,B1,...Bn\></tt> if \c E
- /// matches all \c Bx for \c x in <tt>[0,n)</tt>.
- /// \li An expression \c E matches <tt>if_\<T,U,V\></tt> if
- /// <tt>boost::result_of\<when\<_,T\>(E,int,int)\>::::type::value</tt>
- /// is \c true and \c E matches \c U; or, if
- /// <tt>boost::result_of\<when\<_,T\>(E,int,int)\>::::type::value</tt>
- /// is \c false and \c E matches \c V. (Note: \c U defaults to \c _
- /// and \c V defaults to \c not_\<_\>.)
- /// \li An expression \c E matches <tt>not_\<T\></tt> if \c E does
- /// not match \c T.
- /// \li An expression \c E matches <tt>switch_\<C\></tt> if
- /// \c E matches <tt>C::case_\<E::proto_tag\></tt>.
- ///
- /// A terminal expression <tt>expr\<AT,term\<A\> \></tt> matches
- /// a grammar <tt>expr\<BT,term\<B\> \></tt> if \c BT is \c AT or
- /// \c proto::_ and if one of the following is true:
- ///
- /// \li \c B is the wildcard pattern, \c _
- /// \li \c A is \c B
- /// \li \c A is <tt>B &</tt>
- /// \li \c A is <tt>B const &</tt>
- /// \li \c B is <tt>exact\<A\></tt>
- /// \li \c B is <tt>convertible_to\<X\></tt> and
- /// <tt>is_convertible\<A,X\>::::value</tt> is \c true.
- /// \li \c A is <tt>X[M]</tt> or <tt>X(&)[M]</tt> and
- /// \c B is <tt>X[proto::N]</tt>.
- /// \li \c A is <tt>X(&)[M]</tt> and \c B is <tt>X(&)[proto::N]</tt>.
- /// \li \c A is <tt>X[M]</tt> or <tt>X(&)[M]</tt> and
- /// \c B is <tt>X*</tt>.
- /// \li \c B lambda-matches \c A (see below).
- ///
- /// A type \c B lambda-matches \c A if one of the following is true:
- ///
- /// \li \c B is \c A
- /// \li \c B is the wildcard pattern, \c _
- /// \li \c B is <tt>T\<B0,B1,...Bn\></tt> and \c A is
- /// <tt>T\<A0,A1,...An\></tt> and for each \c x in
- /// <tt>[0,n)</tt>, \c Ax and \c Bx are types
- /// such that \c Ax lambda-matches \c Bx
- template<typename Expr, typename Grammar>
- struct matches
- : detail::matches_<
- typename Expr::proto_base_expr
- , typename Grammar::proto_base_expr
- >
- {};
+ /// \brief A Boolean metafunction that evaluates whether a given
+ /// expression type matches a grammar.
+ ///
+ /// <tt>matches\<Expr,Grammar\></tt> inherits (indirectly) from
+ /// \c mpl::true_ if <tt>Expr::proto_grammar</tt> matches
+ /// <tt>Grammar::proto_grammar</tt>, and from \c mpl::false_
+ /// otherwise.
+ ///
+ /// Non-terminal expressions are matched against a grammar
+ /// according to the following rules:
+ ///
+ /// \li The wildcard pattern, \c _, matches any expression.
+ /// \li An expression <tt>expr\<AT, listN\<A0,A1,...An\> \></tt>
+ /// matches a grammar <tt>expr\<BT, listN\<B0,B1,...Bn\> \></tt>
+ /// if \c BT is \c _ or \c AT, and if \c Ax matches \c Bx for
+ /// each \c x in <tt>[0,n)</tt>.
+ /// \li An expression <tt>expr\<AT, listN\<A0,...An,U0,...Um\> \></tt>
+ /// matches a grammar <tt>expr\<BT, listM\<B0,...Bn,vararg\<V\> \> \></tt>
+ /// if \c BT is \c _ or \c AT, and if \c Ax matches \c Bx
+ /// for each \c x in <tt>[0,n)</tt> and if \c Ux matches \c V
+ /// for each \c x in <tt>[0,m)</tt>.
+ /// \li An expression \c E matches <tt>or_\<B0,B1,...Bn\></tt> if \c E
+ /// matches some \c Bx for \c x in <tt>[0,n)</tt>.
+ /// \li An expression \c E matches <tt>and_\<B0,B1,...Bn\></tt> if \c E
+ /// matches all \c Bx for \c x in <tt>[0,n)</tt>.
+ /// \li An expression \c E matches <tt>if_\<T,U,V\></tt> if
+ /// <tt>boost::result_of\<when\<_,T\>(E,int,int)\>::type::value</tt>
+ /// is \c true and \c E matches \c U; or, if
+ /// <tt>boost::result_of\<when\<_,T\>(E,int,int)\>::type::value</tt>
+ /// is \c false and \c E matches \c V. (Note: \c U defaults to \c _
+ /// and \c V defaults to \c not_\<_\>.)
+ /// \li An expression \c E matches <tt>not_\<T\></tt> if \c E does
+ /// not match \c T.
+ /// \li An expression \c E matches <tt>switch_\<C\></tt> if
+ /// \c E matches <tt>C::case_\<E::proto_tag\></tt>.
+ ///
+ /// A terminal expression <tt>expr\<AT,term\<A\> \></tt> matches
+ /// a grammar <tt>expr\<BT,term\<B\> \></tt> if \c BT is \c AT or
+ /// \c proto::_ and if one of the following is true:
+ ///
+ /// \li \c B is the wildcard pattern, \c _
+ /// \li \c A is \c B
+ /// \li \c A is <tt>B &</tt>
+ /// \li \c A is <tt>B const &</tt>
+ /// \li \c B is <tt>exact\<A\></tt>
+ /// \li \c B is <tt>convertible_to\<X\></tt> and
+ /// <tt>is_convertible\<A,X\>::value</tt> is \c true.
+ /// \li \c A is <tt>X[M]</tt> or <tt>X(&)[M]</tt> and
+ /// \c B is <tt>X[proto::N]</tt>.
+ /// \li \c A is <tt>X(&)[M]</tt> and \c B is <tt>X(&)[proto::N]</tt>.
+ /// \li \c A is <tt>X[M]</tt> or <tt>X(&)[M]</tt> and
+ /// \c B is <tt>X*</tt>.
+ /// \li \c B lambda-matches \c A (see below).
+ ///
+ /// A type \c B lambda-matches \c A if one of the following is true:
+ ///
+ /// \li \c B is \c A
+ /// \li \c B is the wildcard pattern, \c _
+ /// \li \c B is <tt>T\<B0,B1,...Bn\></tt> and \c A is
+ /// <tt>T\<A0,A1,...An\></tt> and for each \c x in
+ /// <tt>[0,n)</tt>, \c Ax and \c Bx are types
+ /// such that \c Ax lambda-matches \c Bx
+ template<typename Expr, typename Grammar>
+ struct matches
+ : detail::matches_<
+ typename Expr::proto_grammar
+ , typename Grammar::proto_grammar
+ >
+ {};
- /// INTERNAL ONLY
- ///
- template<typename Expr, typename Grammar>
- struct matches<Expr &, Grammar>
- : detail::matches_<
- typename Expr::proto_base_expr
- , typename Grammar::proto_base_expr
- >
- {};
- }
+ /// INTERNAL ONLY
+ ///
+ template<typename Expr, typename Grammar>
+ struct matches<Expr &, Grammar>
+ : detail::matches_<
+ typename Expr::proto_grammar
+ , typename Grammar::proto_grammar
+ >
+ {};
- namespace wildcardns_
+ /// \brief A wildcard grammar element that matches any expression,
+ /// and a transform that returns the current expression unchanged.
+ ///
+ /// The wildcard type, \c _, is a grammar element such that
+ /// <tt>matches\<E,_\>::value</tt> is \c true for any expression
+ /// type \c E.
+ ///
+ /// The wildcard can also be used as a stand-in for a template
+ /// argument when matching terminals. For instance, the following
+ /// is a grammar that will match any <tt>std::complex\<\></tt>
+ /// terminal:
+ ///
+ /// \code
+ /// BOOST_MPL_ASSERT((
+ /// matches<
+ /// terminal<std::complex<double> >::type
+ /// , terminal<std::complex< _ > >
+ /// >
+ /// ));
+ /// \endcode
+ ///
+ /// When used as a transform, \c _ returns the current expression
+ /// unchanged. For instance, in the following, \c _ is used with
+ /// the \c fold\<\> transform to fold the children of a node:
+ ///
+ /// \code
+ /// struct CountChildren
+ /// : or_<
+ /// // Terminals have no children
+ /// when<terminal<_>, mpl::int_<0>()>
+ /// // Use fold<> to count the children of non-terminals
+ /// , otherwise<
+ /// fold<
+ /// _ // <-- fold the current expression
+ /// , mpl::int_<0>()
+ /// , mpl::plus<_state, mpl::int_<1> >()
+ /// >
+ /// >
+ /// >
+ /// {};
+ /// \endcode
+ struct _ : transform<_>
{
+ typedef _ proto_grammar;
- /// \brief A wildcard grammar element that matches any expression,
- /// and a transform that returns the current expression unchanged.
- ///
- /// The wildcard type, \c _, is a grammar element such that
- /// <tt>matches\<E,_\>::::value</tt> is \c true for any expression
- /// type \c E.
- ///
- /// The wildcard can also be used as a stand-in for a template
- /// argument when matching terminals. For instance, the following
- /// is a grammar that will match any <tt>std::complex\<\></tt>
- /// terminal:
- ///
- /// \code
- /// BOOST_MPL_ASSERT((
- /// matches<
- /// terminal<std::complex<double> >::type
- /// , terminal<std::complex< _ > >
- /// >
- /// ));
- /// \endcode
- ///
- /// When used as a transform, \c _ returns the current expression
- /// unchanged. For instance, in the following, \c _ is used with
- /// the \c fold\<\> transform to fold the children of a node:
- ///
- /// \code
- /// struct CountChildren
- /// : or_<
- /// // Terminals have no children
- /// when<terminal<_>, mpl::int_<0>()>
- /// // Use fold<> to count the children of non-terminals
- /// , otherwise<
- /// fold<
- /// _ // <-- fold the current expression
- /// , mpl::int_<0>()
- /// , mpl::plus<_state, mpl::int_<1> >()
- /// >
- /// >
- /// >
- /// {};
- /// \endcode
- struct _ : transform<_>
+ template<typename Expr, typename State, typename Data>
+ struct impl : transform_impl<Expr, State, Data>
{
- typedef _ proto_base_expr;
+ typedef Expr result_type;
- template<typename Expr, typename State, typename Data>
- struct impl : transform_impl<Expr, State, Data>
+ /// \param expr An expression
+ /// \return \c e
+ #ifdef BOOST_PROTO_STRICT_RESULT_OF
+ result_type
+ #else
+ typename impl::expr_param
+ #endif
+ operator()(
+ typename impl::expr_param e
+ , typename impl::state_param
+ , typename impl::data_param
+ ) const
{
- typedef Expr result_type;
-
- /// \param expr An expression
- /// \return \c e
- #ifdef BOOST_PROTO_STRICT_RESULT_OF
- result_type
- #else
- typename impl::expr_param
- #endif
- operator()(
- typename impl::expr_param e
- , typename impl::state_param
- , typename impl::data_param
- ) const
- {
- return e;
- }
- };
+ return e;
+ }
};
- }
+ };
namespace detail
{
@@ -598,289 +599,286 @@
{};
}
- namespace control
+ /// \brief Inverts the set of expressions matched by a grammar. When
+ /// used as a transform, \c not_\<\> returns the current expression
+ /// unchanged.
+ ///
+ /// If an expression type \c E does not match a grammar \c G, then
+ /// \c E \e does match <tt>not_\<G\></tt>. For example,
+ /// <tt>not_\<terminal\<_\> \></tt> will match any non-terminal.
+ template<typename Grammar>
+ struct not_ : transform<not_<Grammar> >
{
- /// \brief Inverts the set of expressions matched by a grammar. When
- /// used as a transform, \c not_\<\> returns the current expression
- /// unchanged.
- ///
- /// If an expression type \c E does not match a grammar \c G, then
- /// \c E \e does match <tt>not_\<G\></tt>. For example,
- /// <tt>not_\<terminal\<_\> \></tt> will match any non-terminal.
- template<typename Grammar>
- struct not_ : transform<not_<Grammar> >
- {
- typedef not_ proto_base_expr;
+ typedef not_ proto_grammar;
- template<typename Expr, typename State, typename Data>
- struct impl : transform_impl<Expr, State, Data>
- {
- typedef Expr result_type;
-
- /// \param e An expression
- /// \pre <tt>matches\<Expr,not_\>::::value</tt> is \c true.
- /// \return \c e
- #ifdef BOOST_PROTO_STRICT_RESULT_OF
- result_type
- #else
- typename impl::expr_param
- #endif
- operator()(
- typename impl::expr_param e
- , typename impl::state_param
- , typename impl::data_param
- ) const
- {
- return e;
- }
- };
- };
-
- /// \brief Used to select one grammar or another based on the result
- /// of a compile-time Boolean. When used as a transform, \c if_\<\>
- /// selects between two transforms based on a compile-time Boolean.
- ///
- /// When <tt>if_\<If,Then,Else\></tt> is used as a grammar, \c If
- /// must be a Proto transform and \c Then and \c Else must be grammars.
- /// An expression type \c E matches <tt>if_\<If,Then,Else\></tt> if
- /// <tt>boost::result_of\<when\<_,If\>(E,int,int)\>::::type::value</tt>
- /// is \c true and \c E matches \c U; or, if
- /// <tt>boost::result_of\<when\<_,If\>(E,int,int)\>::::type::value</tt>
- /// is \c false and \c E matches \c V.
- ///
- /// The template parameter \c Then defaults to \c _
- /// and \c Else defaults to \c not\<_\>, so an expression type \c E
- /// will match <tt>if_\<If\></tt> if and only if
- /// <tt>boost::result_of\<when\<_,If\>(E,int,int)\>::::type::value</tt>
- /// is \c true.
- ///
- /// \code
- /// // A grammar that only matches integral terminals,
- /// // using is_integral<> from Boost.Type_traits.
- /// struct IsIntegral
- /// : and_<
- /// terminal<_>
- /// , if_< is_integral<_value>() >
- /// >
- /// {};
- /// \endcode
- ///
- /// When <tt>if_\<If,Then,Else\></tt> is used as a transform, \c If,
- /// \c Then and \c Else must be Proto transforms. When applying
- /// the transform to an expression \c E, state \c S and data \c V,
- /// if <tt>boost::result_of\<when\<_,If\>(E,S,V)\>::::type::value</tt>
- /// is \c true then the \c Then transform is applied; otherwise
- /// the \c Else transform is applied.
- ///
- /// \code
- /// // Match a terminal. If the terminal is integral, return
- /// // mpl::true_; otherwise, return mpl::false_.
- /// struct IsIntegral2
- /// : when<
- /// terminal<_>
- /// , if_<
- /// is_integral<_value>()
- /// , mpl::true_()
- /// , mpl::false_()
- /// >
- /// >
- /// {};
- /// \endcode
- template<
- typename If
- , typename Then // = _
- , typename Else // = not_<_>
- >
- struct if_ : transform<if_<If, Then, Else> >
+ template<typename Expr, typename State, typename Data>
+ struct impl : transform_impl<Expr, State, Data>
{
- typedef if_ proto_base_expr;
+ typedef Expr result_type;
- template<typename Expr, typename State, typename Data>
- struct impl : transform_impl<Expr, State, Data>
+ /// \param e An expression
+ /// \pre <tt>matches\<Expr,not_\>::value</tt> is \c true.
+ /// \return \c e
+ #ifdef BOOST_PROTO_STRICT_RESULT_OF
+ result_type
+ #else
+ typename impl::expr_param
+ #endif
+ operator()(
+ typename impl::expr_param e
+ , typename impl::state_param
+ , typename impl::data_param
+ ) const
{
- typedef
- typename when<_, If>::template impl<Expr, State, Data>::result_type
- condition;
-
- typedef
- typename mpl::if_c<
- remove_reference<condition>::type::value
- , when<_, Then>
- , when<_, Else>
- >::type
- which;
-
- typedef typename which::template impl<Expr, State, Data>::result_type result_type;
-
- /// \param e An expression
- /// \param s The current state
- /// \param d A data of arbitrary type
- /// \return <tt>which::impl<Expr, State, Data>()(e, s, d)</tt>
- result_type operator ()(
- typename impl::expr_param e
- , typename impl::state_param s
- , typename impl::data_param d
- ) const
- {
- return typename which::template impl<Expr, State, Data>()(e, s, d);
- }
- };
+ return e;
+ }
};
+ };
+
+ /// \brief Used to select one grammar or another based on the result
+ /// of a compile-time Boolean. When used as a transform, \c if_\<\>
+ /// selects between two transforms based on a compile-time Boolean.
+ ///
+ /// When <tt>if_\<If,Then,Else\></tt> is used as a grammar, \c If
+ /// must be a Proto transform and \c Then and \c Else must be grammars.
+ /// An expression type \c E matches <tt>if_\<If,Then,Else\></tt> if
+ /// <tt>boost::result_of\<when\<_,If\>(E,int,int)\>::type::value</tt>
+ /// is \c true and \c E matches \c U; or, if
+ /// <tt>boost::result_of\<when\<_,If\>(E,int,int)\>::type::value</tt>
+ /// is \c false and \c E matches \c V.
+ ///
+ /// The template parameter \c Then defaults to \c _
+ /// and \c Else defaults to \c not\<_\>, so an expression type \c E
+ /// will match <tt>if_\<If\></tt> if and only if
+ /// <tt>boost::result_of\<when\<_,If\>(E,int,int)\>::type::value</tt>
+ /// is \c true.
+ ///
+ /// \code
+ /// // A grammar that only matches integral terminals,
+ /// // using is_integral<> from Boost.Type_traits.
+ /// struct IsIntegral
+ /// : and_<
+ /// terminal<_>
+ /// , if_< is_integral<_value>() >
+ /// >
+ /// {};
+ /// \endcode
+ ///
+ /// When <tt>if_\<If,Then,Else\></tt> is used as a transform, \c If,
+ /// \c Then and \c Else must be Proto transforms. When applying
+ /// the transform to an expression \c E, state \c S and data \c V,
+ /// if <tt>boost::result_of\<when\<_,If\>(E,S,V)\>::type::value</tt>
+ /// is \c true then the \c Then transform is applied; otherwise
+ /// the \c Else transform is applied.
+ ///
+ /// \code
+ /// // Match a terminal. If the terminal is integral, return
+ /// // mpl::true_; otherwise, return mpl::false_.
+ /// struct IsIntegral2
+ /// : when<
+ /// terminal<_>
+ /// , if_<
+ /// is_integral<_value>()
+ /// , mpl::true_()
+ /// , mpl::false_()
+ /// >
+ /// >
+ /// {};
+ /// \endcode
+ template<
+ typename If
+ , typename Then // = _
+ , typename Else // = not_<_>
+ >
+ struct if_ : transform<if_<If, Then, Else> >
+ {
+ typedef if_ proto_grammar;
- /// \brief For matching one of a set of alternate grammars. Alternates
- /// tried in order to avoid ambiguity. When used as a transform, \c or_\<\>
- /// applies the transform associated with the first grammar that matches
- /// the expression.
- ///
- /// An expression type \c E matches <tt>or_\<B0,B1,...Bn\></tt> if \c E
- /// matches any \c Bx for \c x in <tt>[0,n)</tt>.
- ///
- /// When applying <tt>or_\<B0,B1,...Bn\></tt> as a transform with an
- /// expression \c e of type \c E, state \c s and data \c d, it is
- /// equivalent to <tt>Bx()(e, s, d)</tt>, where \c x is the lowest
- /// number such that <tt>matches\<E,Bx\>::::value</tt> is \c true.
- template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G)>
- struct or_ : transform<or_<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, G)> >
+ template<typename Expr, typename State, typename Data>
+ struct impl : transform_impl<Expr, State, Data>
{
- typedef or_ proto_base_expr;
+ typedef
+ typename when<_, If>::template impl<Expr, State, Data>::result_type
+ condition;
+
+ typedef
+ typename mpl::if_c<
+ remove_reference<condition>::type::value
+ , when<_, Then>
+ , when<_, Else>
+ >::type
+ which;
+
+ typedef typename which::template impl<Expr, State, Data>::result_type result_type;
/// \param e An expression
/// \param s The current state
/// \param d A data of arbitrary type
- /// \pre <tt>matches\<Expr,or_\>::::value</tt> is \c true.
- /// \return <tt>which()(e, s, d)</tt>, where <tt>which</tt> is the
- /// sub-grammar that matched <tt>Expr</tt>.
-
- template<typename Expr, typename State, typename Data>
- struct impl
- : detail::matches_<typename Expr::proto_base_expr, or_>
- ::which::template impl<Expr, State, Data>
- {};
-
- template<typename Expr, typename State, typename Data>
- struct impl<Expr &, State, Data>
- : detail::matches_<typename Expr::proto_base_expr, or_>
- ::which::template impl<Expr &, State, Data>
- {};
+ /// \return <tt>which::impl<Expr, State, Data>()(e, s, d)</tt>
+ result_type operator ()(
+ typename impl::expr_param e
+ , typename impl::state_param s
+ , typename impl::data_param d
+ ) const
+ {
+ return typename which::template impl<Expr, State, Data>()(e, s, d);
+ }
};
+ };
- /// \brief For matching all of a set of grammars. When used as a
- /// transform, \c and_\<\> applies the transforms associated with
- /// the each grammar in the set, and returns the result of the last.
- ///
- /// An expression type \c E matches <tt>and_\<B0,B1,...Bn\></tt> if \c E
- /// matches all \c Bx for \c x in <tt>[0,n)</tt>.
- ///
- /// When applying <tt>and_\<B0,B1,...Bn\></tt> as a transform with an
- /// expression \c e, state \c s and data \c d, it is
- /// equivalent to <tt>(B0()(e, s, d),B1()(e, s, d),...Bn()(e, s, d))</tt>.
- template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G)>
- struct and_ : transform<and_<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, G)> >
- {
- typedef and_ proto_base_expr;
+ /// \brief For matching one of a set of alternate grammars. Alternates
+ /// tried in order to avoid ambiguity. When used as a transform, \c or_\<\>
+ /// applies the transform associated with the first grammar that matches
+ /// the expression.
+ ///
+ /// An expression type \c E matches <tt>or_\<B0,B1,...Bn\></tt> if \c E
+ /// matches any \c Bx for \c x in <tt>[0,n)</tt>.
+ ///
+ /// When applying <tt>or_\<B0,B1,...Bn\></tt> as a transform with an
+ /// expression \c e of type \c E, state \c s and data \c d, it is
+ /// equivalent to <tt>Bx()(e, s, d)</tt>, where \c x is the lowest
+ /// number such that <tt>matches\<E,Bx\>::value</tt> is \c true.
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G)>
+ struct or_ : transform<or_<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, G)> >
+ {
+ typedef or_ proto_grammar;
- template<typename Expr, typename State, typename Data>
- struct impl
- : detail::_and_impl<and_, Expr, State, Data>
- {};
- };
+ /// \param e An expression
+ /// \param s The current state
+ /// \param d A data of arbitrary type
+ /// \pre <tt>matches\<Expr,or_\>::value</tt> is \c true.
+ /// \return <tt>which()(e, s, d)</tt>, where <tt>which</tt> is the
+ /// sub-grammar that matched <tt>Expr</tt>.
- /// \brief For matching one of a set of alternate grammars, which
- /// are looked up based on an expression's tag type. When used as a
- /// transform, \c switch_\<\> applies the transform associated with
- /// the grammar that matches the expression.
- ///
- /// \note \c switch_\<\> is functionally identical to \c or_\<\> but
- /// is often more efficient. It does a fast, O(1) lookup based on an
- /// expression's tag type to find a sub-grammar that may potentially
- /// match the expression.
- ///
- /// An expression type \c E matches <tt>switch_\<C\></tt> if \c E
- /// matches <tt>C::case_\<E::proto_tag\></tt>.
- ///
- /// When applying <tt>switch_\<C\></tt> as a transform with an
- /// expression \c e of type \c E, state \c s and data \c d, it is
- /// equivalent to <tt>C::case_\<E::proto_tag\>()(e, s, d)</tt>.
- template<typename Cases>
- struct switch_ : transform<switch_<Cases> >
- {
- typedef switch_ proto_base_expr;
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : detail::matches_<typename Expr::proto_grammar, or_>
+ ::which::template impl<Expr, State, Data>
+ {};
- /// \param e An expression
- /// \param s The current state
- /// \param d A data of arbitrary type
- /// \pre <tt>matches\<Expr,switch_\>::::value</tt> is \c true.
- /// \return <tt>which()(e, s, d)</tt>, where <tt>which</tt> is
- /// <tt>Cases::case_<typename Expr::proto_tag></tt>
-
- template<typename Expr, typename State, typename Data>
- struct impl
- : Cases::template case_<typename Expr::proto_tag>::template impl<Expr, State, Data>
- {};
-
- template<typename Expr, typename State, typename Data>
- struct impl<Expr &, State, Data>
- : Cases::template case_<typename Expr::proto_tag>::template impl<Expr &, State, Data>
- {};
- };
+ template<typename Expr, typename State, typename Data>
+ struct impl<Expr &, State, Data>
+ : detail::matches_<typename Expr::proto_grammar, or_>
+ ::which::template impl<Expr &, State, Data>
+ {};
+ };
+
+ /// \brief For matching all of a set of grammars. When used as a
+ /// transform, \c and_\<\> applies the transforms associated with
+ /// the each grammar in the set, and returns the result of the last.
+ ///
+ /// An expression type \c E matches <tt>and_\<B0,B1,...Bn\></tt> if \c E
+ /// matches all \c Bx for \c x in <tt>[0,n)</tt>.
+ ///
+ /// When applying <tt>and_\<B0,B1,...Bn\></tt> as a transform with an
+ /// expression \c e, state \c s and data \c d, it is
+ /// equivalent to <tt>(B0()(e, s, d),B1()(e, s, d),...Bn()(e, s, d))</tt>.
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G)>
+ struct and_ : transform<and_<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, G)> >
+ {
+ typedef and_ proto_grammar;
- /// \brief For forcing exact matches of terminal types.
- ///
- /// By default, matching terminals ignores references and
- /// cv-qualifiers. For instance, a terminal expression of
- /// type <tt>terminal\<int const &\>::::type</tt> will match
- /// the grammar <tt>terminal\<int\></tt>. If that is not
- /// desired, you can force an exact match with
- /// <tt>terminal\<exact\<int\> \></tt>. This will only
- /// match integer terminals where the terminal is held by
- /// value.
- template<typename T>
- struct exact
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : detail::_and_impl<and_, Expr, State, Data>
{};
+ };
- /// \brief For matching terminals that are convertible to
- /// a type.
- ///
- /// Use \c convertible_to\<\> to match a terminal that is
- /// convertible to some type. For example, the grammar
- /// <tt>terminal\<convertible_to\<int\> \></tt> will match
- /// any terminal whose argument is convertible to an integer.
- ///
- /// \note The trait \c is_convertible\<\> from Boost.Type_traits
- /// is used to determinal convertibility.
- template<typename T>
- struct convertible_to
+ /// \brief For matching one of a set of alternate grammars, which
+ /// are looked up based on an expression's tag type. When used as a
+ /// transform, \c switch_\<\> applies the transform associated with
+ /// the grammar that matches the expression.
+ ///
+ /// \note \c switch_\<\> is functionally identical to \c or_\<\> but
+ /// is often more efficient. It does a fast, O(1) lookup based on an
+ /// expression's tag type to find a sub-grammar that may potentially
+ /// match the expression.
+ ///
+ /// An expression type \c E matches <tt>switch_\<C\></tt> if \c E
+ /// matches <tt>C::case_\<E::proto_tag\></tt>.
+ ///
+ /// When applying <tt>switch_\<C\></tt> as a transform with an
+ /// expression \c e of type \c E, state \c s and data \c d, it is
+ /// equivalent to <tt>C::case_\<E::proto_tag\>()(e, s, d)</tt>.
+ template<typename Cases>
+ struct switch_ : transform<switch_<Cases> >
+ {
+ typedef switch_ proto_grammar;
+
+ /// \param e An expression
+ /// \param s The current state
+ /// \param d A data of arbitrary type
+ /// \pre <tt>matches\<Expr,switch_\>::value</tt> is \c true.
+ /// \return <tt>which()(e, s, d)</tt>, where <tt>which</tt> is
+ /// <tt>Cases::case_<typename Expr::proto_tag></tt>
+
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : Cases::template case_<typename Expr::proto_tag>::template impl<Expr, State, Data>
{};
- /// \brief For matching a Grammar to a variable number of
- /// sub-expressions.
- ///
- /// An expression type <tt>expr\<AT, listN\<A0,...An,U0,...Um\> \></tt>
- /// matches a grammar <tt>expr\<BT, listM\<B0,...Bn,vararg\<V\> \> \></tt>
- /// if \c BT is \c _ or \c AT, and if \c Ax matches \c Bx
- /// for each \c x in <tt>[0,n)</tt> and if \c Ux matches \c V
- /// for each \c x in <tt>[0,m)</tt>.
- ///
- /// For example:
- ///
- /// \code
- /// // Match any function call expression, irregardless
- /// // of the number of function arguments:
- /// struct Function
- /// : function< vararg<_> >
- /// {};
- /// \endcode
- ///
- /// When used as a transform, <tt>vararg\<G\></tt> applies
- /// <tt>G</tt>'s transform.
- template<typename Grammar>
- struct vararg
- : Grammar
- {
- /// INTERNAL ONLY
- typedef void proto_is_vararg_;
- };
- }
+ template<typename Expr, typename State, typename Data>
+ struct impl<Expr &, State, Data>
+ : Cases::template case_<typename Expr::proto_tag>::template impl<Expr &, State, Data>
+ {};
+ };
+
+ /// \brief For forcing exact matches of terminal types.
+ ///
+ /// By default, matching terminals ignores references and
+ /// cv-qualifiers. For instance, a terminal expression of
+ /// type <tt>terminal\<int const &\>::type</tt> will match
+ /// the grammar <tt>terminal\<int\></tt>. If that is not
+ /// desired, you can force an exact match with
+ /// <tt>terminal\<exact\<int\> \></tt>. This will only
+ /// match integer terminals where the terminal is held by
+ /// value.
+ template<typename T>
+ struct exact
+ {};
+
+ /// \brief For matching terminals that are convertible to
+ /// a type.
+ ///
+ /// Use \c convertible_to\<\> to match a terminal that is
+ /// convertible to some type. For example, the grammar
+ /// <tt>terminal\<convertible_to\<int\> \></tt> will match
+ /// any terminal whose argument is convertible to an integer.
+ ///
+ /// \note The trait \c is_convertible\<\> from Boost.Type_traits
+ /// is used to determinal convertibility.
+ template<typename T>
+ struct convertible_to
+ {};
+
+ /// \brief For matching a Grammar to a variable number of
+ /// sub-expressions.
+ ///
+ /// An expression type <tt>expr\<AT, listN\<A0,...An,U0,...Um\> \></tt>
+ /// matches a grammar <tt>expr\<BT, listM\<B0,...Bn,vararg\<V\> \> \></tt>
+ /// if \c BT is \c _ or \c AT, and if \c Ax matches \c Bx
+ /// for each \c x in <tt>[0,n)</tt> and if \c Ux matches \c V
+ /// for each \c x in <tt>[0,m)</tt>.
+ ///
+ /// For example:
+ ///
+ /// \code
+ /// // Match any function call expression, irregardless
+ /// // of the number of function arguments:
+ /// struct Function
+ /// : function< vararg<_> >
+ /// {};
+ /// \endcode
+ ///
+ /// When used as a transform, <tt>vararg\<G\></tt> applies
+ /// <tt>G</tt>'s transform.
+ template<typename Grammar>
+ struct vararg
+ : Grammar
+ {
+ /// INTERNAL ONLY
+ typedef void proto_is_vararg_;
+ };
/// INTERNAL ONLY
///
@@ -981,13 +979,13 @@
template<bool B, typename Expr, BOOST_PP_ENUM_PARAMS(N, typename G)>
struct BOOST_PP_CAT(or_, N)
#if 2 == N
- : mpl::bool_<matches_<Expr, typename G1::proto_base_expr>::value>
+ : mpl::bool_<matches_<Expr, typename G1::proto_grammar>::value>
{
typedef G1 which;
};
#else
: BOOST_PP_CAT(or_, BOOST_PP_DEC(N))<
- matches_<Expr, typename G1::proto_base_expr>::value
+ matches_<Expr, typename G1::proto_grammar>::value
, Expr, BOOST_PP_ENUM_SHIFTED_PARAMS(N, G)
>
{};
@@ -1004,8 +1002,8 @@
template<typename Expr, BOOST_PP_ENUM_PARAMS(N, typename G)>
struct matches_<Expr, proto::or_<BOOST_PP_ENUM_PARAMS(N, G)> >
: BOOST_PP_CAT(or_, N)<
- matches_<typename Expr::proto_base_expr, typename G0::proto_base_expr>::value,
- typename Expr::proto_base_expr, BOOST_PP_ENUM_PARAMS(N, G)
+ matches_<Expr, typename G0::proto_grammar>::value,
+ Expr, BOOST_PP_ENUM_PARAMS(N, G)
>
{};
@@ -1029,7 +1027,7 @@
struct vararg_matches_impl<Args, Back, N, To>
: and_2<
matches_<
- typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_base_expr
+ typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_grammar
, Back
>::value
, vararg_matches_impl<Args, Back, N + 1, To>
@@ -1039,7 +1037,7 @@
template<typename Args, typename Back>
struct vararg_matches_impl<Args, Back, N, N>
: matches_<
- typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_base_expr
+ typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_grammar
, Back
>
{};
@@ -1061,7 +1059,7 @@
{};
template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::expr<Tag, Args1, N>, proto::expr<Tag, Args2, N> >
+ struct matches_< proto::basic_expr<Tag, Args1, N>, proto::basic_expr<Tag, Args2, N> >
: BOOST_PP_CAT(and_, N)<
BOOST_PROTO_MATCHES_N_FUN(~, 0, ~)::value,
BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_MATCHES_N_FUN, ~)
@@ -1069,7 +1067,7 @@
{};
template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::expr<Tag, Args1, N>, proto::expr<proto::_, Args2, N> >
+ struct matches_< proto::basic_expr<Tag, Args1, N>, proto::basic_expr<proto::_, Args2, N> >
: BOOST_PP_CAT(and_, N)<
BOOST_PROTO_MATCHES_N_FUN(~, 0, ~)::value,
BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_MATCHES_N_FUN, ~)
Modified: branches/release/boost/proto/operators.hpp
==============================================================================
--- branches/release/boost/proto/operators.hpp (original)
+++ branches/release/boost/proto/operators.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -15,7 +15,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/tags.hpp>
-#include <boost/proto/expr.hpp>
#include <boost/proto/domain.hpp>
#include <boost/proto/matches.hpp>
#include <boost/proto/generate.hpp>
@@ -43,7 +42,10 @@
template<typename Domain, typename Trait, typename Tag, typename Arg>
struct enable_unary<Domain, proto::_, Trait, Tag, Arg>
- : boost::lazy_enable_if_c<Trait::value, result_of::make_expr<Tag, Domain, Arg &> >
+ : boost::lazy_enable_if_c<
+ Trait::value
+ , result_of::make_expr<Tag, Domain, Arg &>
+ >
{};
template<typename Trait, typename Tag, typename Arg>
@@ -62,8 +64,8 @@
: boost::lazy_enable_if_c<
boost::mpl::and_<
Trait
- , lazy_matches<proto::result_of::as_child<Left>, Grammar>
- , lazy_matches<proto::result_of::as_child<Right>, Grammar>
+ , lazy_matches<result_of::as_child<Left>, Grammar>
+ , lazy_matches<result_of::as_child<Right>, Grammar>
, lazy_matches<result_of::make_expr<Tag, Domain, Left &, Right &>, Grammar>
>::value
, result_of::make_expr<Tag, Domain, Left &, Right &>
@@ -72,7 +74,10 @@
template<typename Domain, typename Trait, typename Tag, typename Left, typename Right>
struct enable_binary<Domain, proto::_, Trait, Tag, Left, Right>
- : boost::lazy_enable_if_c<Trait::value, result_of::make_expr<Tag, Domain, Left &, Right &> >
+ : boost::lazy_enable_if_c<
+ Trait::value
+ , result_of::make_expr<Tag, Domain, Left &, Right &>
+ >
{};
template<typename Trait, typename Tag, typename Left, typename Right>
@@ -103,7 +108,7 @@
>::type const \
operator OP(Arg &arg BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
{ \
- return boost::proto::functional::make_expr<TAG, DOMAIN>::impl<Arg &>()(arg); \
+ return boost::proto::detail::make_expr_<TAG, DOMAIN, Arg &>()(arg); \
} \
\
template<typename Arg> \
@@ -116,7 +121,7 @@
>::type const \
operator OP(Arg const &arg BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
{ \
- return boost::proto::functional::make_expr<TAG, DOMAIN>::impl<Arg const &>()(arg); \
+ return boost::proto::detail::make_expr_<TAG, DOMAIN, Arg const &>()(arg); \
} \
/**/
@@ -132,8 +137,7 @@
>::type const \
operator OP(Left &left, Right &right) \
{ \
- return boost::proto::functional::make_expr<TAG, DOMAIN>:: \
- impl<Left &, Right &>()(left, right); \
+ return boost::proto::detail::make_expr_<TAG, DOMAIN, Left &, Right &>()(left, right); \
} \
\
template<typename Left, typename Right> \
@@ -147,8 +151,7 @@
>::type const \
operator OP(Left &left, Right const &right) \
{ \
- return boost::proto::functional::make_expr<TAG, DOMAIN>:: \
- impl<Left &, Right const &>()(left, right); \
+ return boost::proto::detail::make_expr_<TAG, DOMAIN, Left &, Right const &>()(left, right); \
} \
\
template<typename Left, typename Right> \
@@ -162,8 +165,7 @@
>::type const \
operator OP(Left const &left, Right &right) \
{ \
- return boost::proto::functional::make_expr<TAG, DOMAIN>:: \
- impl<Left const &, Right &>()(left, right); \
+ return boost::proto::detail::make_expr_<TAG, DOMAIN, Left const &, Right &>()(left, right); \
} \
\
template<typename Left, typename Right> \
@@ -177,8 +179,7 @@
>::type const \
operator OP(Left const &left, Right const &right) \
{ \
- return boost::proto::functional::make_expr<TAG, DOMAIN>:: \
- impl<Left const &, Right const &>()(left, right); \
+ return boost::proto::detail::make_expr_<TAG, DOMAIN, Left const &, Right const &>()(left, right);\
} \
/**/
@@ -241,10 +242,22 @@
// if_else, for the non-overloadable ternary conditional operator ?:
template<typename A0, typename A1, typename A2>
- typename result_of::make_expr<tag::if_else_, deduce_domain, A0 const &, A1 const &, A2 const &>::type const
+ typename result_of::make_expr<
+ tag::if_else_
+ , deduce_domain
+ , A0 const &
+ , A1 const &
+ , A2 const &
+ >::type const
if_else(A0 const &a0, A1 const &a1, A2 const &a2)
{
- return functional::make_expr<tag::if_else_>::impl<A0 const &, A1 const &, A2 const &>()(a0, a1, a2);
+ return proto::detail::make_expr_<
+ tag::if_else_
+ , deduce_domain
+ , A0 const &
+ , A1 const &
+ , A2 const &
+ >()(a0, a1, a2);
}
}
Modified: branches/release/boost/proto/proto_fwd.hpp
==============================================================================
--- branches/release/boost/proto/proto_fwd.hpp (original)
+++ branches/release/boost/proto/proto_fwd.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -92,6 +92,7 @@
struct dont_care;
struct undefined; // leave this undefined
+ struct not_a_valid_type;
struct private_type_
{
@@ -165,21 +166,12 @@
typedef detail::ignore const ignore;
- namespace argsns_
- {
- template<typename Arg0>
- struct term;
-
- #define M0(Z, N, DATA) \
- template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename Arg)> struct BOOST_PP_CAT(list, N); \
- /**/
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M0, ~)
- #undef M0
- }
+ template<typename Arg0>
+ struct term;
- using argsns_::term;
-
- #define M0(Z, N, DATA) using argsns_::BOOST_PP_CAT(list, N);
+ #define M0(Z, N, DATA) \
+ template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename Arg)> struct BOOST_PP_CAT(list, N); \
+ /**/
BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M0, ~)
#undef M0
@@ -243,62 +235,50 @@
}
////////////////////////////////////////////////////////////////////////////////////////////////
- namespace wildcardns_
- {
- struct _;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////
-
- using wildcardns_::_;
+ struct _;
////////////////////////////////////////////////////////////////////////////////////////////////
- namespace generatorns_
- {
- struct default_generator;
+ struct default_generator;
- template<template<typename> class Extends>
- struct generator;
+ template<template<typename> class Extends>
+ struct generator;
- template<template<typename> class Extends>
- struct pod_generator;
+ template<template<typename> class Extends>
+ struct pod_generator;
- struct by_value_generator;
+ struct by_value_generator;
+
+ template<typename First, typename Second>
+ struct compose_generators;
- template<typename First, typename Second>
- struct compose_generators;
- }
////////////////////////////////////////////////////////////////////////////////////////////////
+ template<
+ typename Generator = default_generator
+ , typename Grammar = proto::_
+ , typename Super = detail::not_a_domain
+ >
+ struct domain;
- using generatorns_::default_generator;
- using generatorns_::generator;
- using generatorns_::pod_generator;
- using generatorns_::by_value_generator;
- using generatorns_::compose_generators;
+ struct default_domain;
- ////////////////////////////////////////////////////////////////////////////////////////////////
- namespace domainns_
- {
- template<
- typename Generator = default_generator
- , typename Grammar = proto::_
- , typename Super = detail::not_a_domain
- >
- struct domain;
+ struct deduce_domain;
- struct default_domain;
+ template<typename Domain, typename Void = void>
+ struct wants_basic_expr;
- struct deduce_domain;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Domain, typename Tag, typename Args, typename Void = void>
+ struct base_expr;
- using domainns_::domain;
- using domainns_::default_domain;
- using domainns_::deduce_domain;
+ template<typename Domain>
+ struct use_basic_expr;
////////////////////////////////////////////////////////////////////////////////////////////////
namespace exprns_
{
template<typename Tag, typename Args, long Arity = Args::arity>
+ struct basic_expr;
+
+ template<typename Tag, typename Args, long Arity = Args::arity>
struct expr;
template<
@@ -317,47 +297,35 @@
////////////////////////////////////////////////////////////////////////////////////////////////
using exprns_::expr;
+ using exprns_::basic_expr;
using exprns_::extends;
using exprns_::is_proto_expr;
- namespace control
- {
- template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G, void)>
- struct or_;
+ template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G, void)>
+ struct or_;
- template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G, void)>
- struct and_;
+ template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G, void)>
+ struct and_;
- template<typename Grammar>
- struct not_;
-
- template<typename Condition, typename Then = _, typename Else = not_<_> >
- struct if_;
+ template<typename Grammar>
+ struct not_;
- template<typename Cases>
- struct switch_;
+ template<typename Condition, typename Then = _, typename Else = not_<_> >
+ struct if_;
- template<typename T>
- struct exact;
+ template<typename Cases>
+ struct switch_;
- template<typename T>
- struct convertible_to;
+ template<typename T>
+ struct exact;
- template<typename Grammar>
- struct vararg;
+ template<typename T>
+ struct convertible_to;
- int const N = INT_MAX;
- }
+ template<typename Grammar>
+ struct vararg;
- using control::if_;
- using control::or_;
- using control::and_;
- using control::not_;
- using control::switch_;
- using control::exact;
- using control::convertible_to;
- using control::vararg;
- using control::N;
+ int const N = INT_MAX;
namespace context
{
@@ -448,100 +416,89 @@
template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename Void = void>
struct unpack_expr;
- template<typename T, typename Void = void>
- struct is_expr;
-
- template<typename T, typename Void = void>
- struct is_domain;
+ }
- template<typename Expr>
- struct tag_of;
+ template<typename T, typename Void = void>
+ struct is_expr;
- template<typename Expr>
- struct arity_of;
+ template<typename T, typename Void = void>
+ struct is_domain;
- template<typename T, typename Void = void>
- struct domain_of;
+ template<typename Expr>
+ struct tag_of;
- template<typename Expr, typename Grammar>
- struct matches;
- }
+ template<typename Expr>
+ struct arity_of;
- using result_of::is_expr;
- using result_of::is_domain;
- using result_of::tag_of;
- using result_of::arity_of;
- using result_of::domain_of;
- using result_of::matches;
+ template<typename T, typename Void = void>
+ struct domain_of;
- namespace op
- {
- // Generic expression metafunctions and
- // grammar elements
- template<typename Tag, typename Arg>
- struct unary_expr;
-
- template<typename Tag, typename Left, typename Right>
- struct binary_expr;
-
- template<typename Tag, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void)>
- struct nary_expr;
-
- // Specific expression metafunctions and
- // grammar elements, for convenience
- template<typename T> struct terminal;
- template<typename T> struct unary_plus;
- template<typename T> struct negate;
- template<typename T> struct dereference;
- template<typename T> struct complement;
- template<typename T> struct address_of;
- template<typename T> struct logical_not;
- template<typename T> struct pre_inc;
- template<typename T> struct pre_dec;
- template<typename T> struct post_inc;
- template<typename T> struct post_dec;
-
- template<typename T, typename U> struct shift_left;
- template<typename T, typename U> struct shift_right;
- template<typename T, typename U> struct multiplies;
- template<typename T, typename U> struct divides;
- template<typename T, typename U> struct modulus;
- template<typename T, typename U> struct plus;
- template<typename T, typename U> struct minus;
- template<typename T, typename U> struct less;
- template<typename T, typename U> struct greater;
- template<typename T, typename U> struct less_equal;
- template<typename T, typename U> struct greater_equal;
- template<typename T, typename U> struct equal_to;
- template<typename T, typename U> struct not_equal_to;
- template<typename T, typename U> struct logical_or;
- template<typename T, typename U> struct logical_and;
- template<typename T, typename U> struct bitwise_and;
- template<typename T, typename U> struct bitwise_or;
- template<typename T, typename U> struct bitwise_xor;
- template<typename T, typename U> struct comma;
- template<typename T, typename U> struct mem_ptr;
-
- template<typename T, typename U> struct assign;
- template<typename T, typename U> struct shift_left_assign;
- template<typename T, typename U> struct shift_right_assign;
- template<typename T, typename U> struct multiplies_assign;
- template<typename T, typename U> struct divides_assign;
- template<typename T, typename U> struct modulus_assign;
- template<typename T, typename U> struct plus_assign;
- template<typename T, typename U> struct minus_assign;
- template<typename T, typename U> struct bitwise_and_assign;
- template<typename T, typename U> struct bitwise_or_assign;
- template<typename T, typename U> struct bitwise_xor_assign;
- template<typename T, typename U> struct subscript;
- template<typename T, typename U> struct member;
- template<typename T, typename U, typename V> struct if_else_;
+ template<typename Expr, typename Grammar>
+ struct matches;
- template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void)>
- struct function;
- }
+ // Generic expression metafunctions and
+ // grammar elements
+ template<typename Tag, typename Arg>
+ struct unary_expr;
+
+ template<typename Tag, typename Left, typename Right>
+ struct binary_expr;
+
+ template<typename Tag, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void)>
+ struct nary_expr;
+
+ // Specific expression metafunctions and
+ // grammar elements, for convenience
+ template<typename T> struct terminal;
+ template<typename T> struct unary_plus;
+ template<typename T> struct negate;
+ template<typename T> struct dereference;
+ template<typename T> struct complement;
+ template<typename T> struct address_of;
+ template<typename T> struct logical_not;
+ template<typename T> struct pre_inc;
+ template<typename T> struct pre_dec;
+ template<typename T> struct post_inc;
+ template<typename T> struct post_dec;
+
+ template<typename T, typename U> struct shift_left;
+ template<typename T, typename U> struct shift_right;
+ template<typename T, typename U> struct multiplies;
+ template<typename T, typename U> struct divides;
+ template<typename T, typename U> struct modulus;
+ template<typename T, typename U> struct plus;
+ template<typename T, typename U> struct minus;
+ template<typename T, typename U> struct less;
+ template<typename T, typename U> struct greater;
+ template<typename T, typename U> struct less_equal;
+ template<typename T, typename U> struct greater_equal;
+ template<typename T, typename U> struct equal_to;
+ template<typename T, typename U> struct not_equal_to;
+ template<typename T, typename U> struct logical_or;
+ template<typename T, typename U> struct logical_and;
+ template<typename T, typename U> struct bitwise_and;
+ template<typename T, typename U> struct bitwise_or;
+ template<typename T, typename U> struct bitwise_xor;
+ template<typename T, typename U> struct comma;
+ template<typename T, typename U> struct mem_ptr;
+
+ template<typename T, typename U> struct assign;
+ template<typename T, typename U> struct shift_left_assign;
+ template<typename T, typename U> struct shift_right_assign;
+ template<typename T, typename U> struct multiplies_assign;
+ template<typename T, typename U> struct divides_assign;
+ template<typename T, typename U> struct modulus_assign;
+ template<typename T, typename U> struct plus_assign;
+ template<typename T, typename U> struct minus_assign;
+ template<typename T, typename U> struct bitwise_and_assign;
+ template<typename T, typename U> struct bitwise_or_assign;
+ template<typename T, typename U> struct bitwise_xor_assign;
+ template<typename T, typename U> struct subscript;
+ template<typename T, typename U> struct member;
+ template<typename T, typename U, typename V> struct if_else_;
- using namespace op;
+ template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void)>
+ struct function;
namespace functional
{
@@ -689,6 +646,7 @@
#define BOOST_PROTO_UNEXPR() typedef int proto_is_expr_;
#define BOOST_PROTO_CALLABLE() typedef void proto_is_callable_;
#define BOOST_PROTO_AGGREGATE() typedef void proto_is_aggregate_;
+ #define BOOST_PROTO_USE_BASIC_EXPR() typedef void proto_use_basic_expr_;
struct callable
{
@@ -725,7 +683,8 @@
template<typename Sequence, typename State, typename Fun>
struct reverse_fold;
- // BUGBUG can we replace fold_tree with fold<flatten(_), state, fun> ?
+ // Q: can we replace fold_tree with fold<flatten(_), state, fun> ?
+ // A: once segmented Fusion works well.
template<typename Sequence, typename State, typename Fun>
struct fold_tree;
Modified: branches/release/boost/proto/proto_typeof.hpp
==============================================================================
--- branches/release/boost/proto/proto_typeof.hpp (original)
+++ branches/release/boost/proto/proto_typeof.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -65,71 +65,72 @@
BOOST_TYPEOF_REGISTER_TYPE(boost::proto::exprns_::is_proto_expr)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::exprns_::expr, (typename)(typename)(long))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::exprns_::basic_expr, (typename)(typename)(long))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::utility::literal, (typename)(typename))
BOOST_TYPEOF_REGISTER_TYPE(boost::proto::detail::not_a_generator)
BOOST_TYPEOF_REGISTER_TYPE(boost::proto::detail::not_a_grammar)
BOOST_TYPEOF_REGISTER_TYPE(boost::proto::detail::not_a_domain)
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::domainns_::domain, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::domain, 3)
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::term, 1)
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list1, 1)
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list2, 2)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::term, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list1, 1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list2, 2)
// can't use PP metaprogramming here because all typeof registrations
// must be on separate lines.
#if BOOST_PROTO_MAX_ARITY >= 3
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list3, 3)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list3, 3)
#endif
#if BOOST_PROTO_MAX_ARITY >= 4
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list4, 4)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list4, 4)
#endif
#if BOOST_PROTO_MAX_ARITY >= 5
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list5, 5)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list5, 5)
#endif
#if BOOST_PROTO_MAX_ARITY >= 6
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list6, 6)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list6, 6)
#endif
#if BOOST_PROTO_MAX_ARITY >= 7
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list7, 7)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list7, 7)
#endif
#if BOOST_PROTO_MAX_ARITY >= 8
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list8, 8)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list8, 8)
#endif
#if BOOST_PROTO_MAX_ARITY >= 9
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list9, 9)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list9, 9)
#endif
#if BOOST_PROTO_MAX_ARITY >= 10
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list10, 10)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list10, 10)
#endif
#if BOOST_PROTO_MAX_ARITY >= 11
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list11, 11)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list11, 11)
#endif
#if BOOST_PROTO_MAX_ARITY >= 12
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list12, 12)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list12, 12)
#endif
#if BOOST_PROTO_MAX_ARITY >= 13
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list13, 13)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list13, 13)
#endif
#if BOOST_PROTO_MAX_ARITY >= 14
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list14, 14)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list14, 14)
#endif
#if BOOST_PROTO_MAX_ARITY >= 15
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list15, 15)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list15, 15)
#endif
#if BOOST_PROTO_MAX_ARITY >= 16
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list16, 16)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list16, 16)
#endif
#if BOOST_PROTO_MAX_ARITY >= 17
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list17, 17)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list17, 17)
#endif
#if BOOST_PROTO_MAX_ARITY >= 18
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list18, 18)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list18, 18)
#endif
#if BOOST_PROTO_MAX_ARITY >= 19
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list19, 19)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list19, 19)
#endif
#if BOOST_PROTO_MAX_ARITY >= 20
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::argsns_::list20, 20)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::list20, 20)
#endif
#define BOOST_PROTO_AUTO(Var, Expr) BOOST_AUTO(Var, boost::proto::deep_copy(Expr))
Modified: branches/release/boost/proto/traits.hpp
==============================================================================
--- branches/release/boost/proto/traits.hpp (original)
+++ branches/release/boost/proto/traits.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -41,6 +41,7 @@
#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/args.hpp>
#include <boost/proto/tags.hpp>
+ #include <boost/proto/generate.hpp>
#include <boost/proto/transform/pass_through.hpp>
#if BOOST_WORKAROUND( BOOST_MSVC, >= 1400 )
@@ -84,19 +85,19 @@
/// to determine whether a function type <tt>R(A1,A2,...AN)</tt> is a
/// callable transform or an object transform. (The former are evaluated
/// using <tt>call\<\></tt> and the later with <tt>make\<\></tt>.) If
- /// <tt>is_callable\<R\>::::value</tt> is \c true, the function type is
+ /// <tt>is_callable\<R\>::value</tt> is \c true, the function type is
/// a callable transform; otherwise, it is an object transform.
///
- /// Unless specialized for a type \c T, <tt>is_callable\<T\>::::value</tt>
+ /// Unless specialized for a type \c T, <tt>is_callable\<T\>::value</tt>
/// is computed as follows:
///
/// \li If \c T is a template type <tt>X\<Y0,Y1,...YN\></tt>, where all \c Yx
- /// are types for \c x in <tt>[0,N]</tt>, <tt>is_callable\<T\>::::value</tt>
- /// is <tt>is_same\<YN, proto::callable\>::::value</tt>.
+ /// are types for \c x in <tt>[0,N]</tt>, <tt>is_callable\<T\>::value</tt>
+ /// is <tt>is_same\<YN, proto::callable\>::value</tt>.
/// \li If \c T has a nested type \c proto_is_callable_ that is a typedef
- /// for \c void, <tt>is_callable\<T\>::::value</tt> is \c true. (Note: this is
+ /// for \c void, <tt>is_callable\<T\>::value</tt> is \c true. (Note: this is
/// the case for any type that derives from \c proto::callable.)
- /// \li Otherwise, <tt>is_callable\<T\>::::value</tt> is \c false.
+ /// \li Otherwise, <tt>is_callable\<T\>::value</tt> is \c false.
template<typename T>
struct is_callable
: proto::detail::is_callable_<T>
@@ -122,6 +123,12 @@
struct is_callable<proto::expr<Tag, Args, N> >
: mpl::false_
{};
+
+ // work around GCC bug
+ template<typename Tag, typename Args, long N>
+ struct is_callable<proto::basic_expr<Tag, Args, N> >
+ : mpl::false_
+ {};
#endif
/// \brief A Boolean metafunction that indicates whether a type requires
@@ -130,7 +137,7 @@
/// <tt>is_aggregate\<\></tt> is used by the <tt>make\<\></tt> transform
/// to determine how to construct an object of some type \c T, given some
/// initialization arguments <tt>a0,a1,...aN</tt>.
- /// If <tt>is_aggregate\<T\>::::value</tt> is \c true, then an object of
+ /// If <tt>is_aggregate\<T\>::value</tt> is \c true, then an object of
/// type T will be initialized as <tt>T t = {a0,a1,...aN};</tt>. Otherwise,
/// it will be initialized as <tt>T t(a0,a1,...aN)</tt>.
template<typename T, typename Void>
@@ -145,6 +152,11 @@
: mpl::true_
{};
+ template<typename Tag, typename Args, long N>
+ struct is_aggregate<proto::basic_expr<Tag, Args, N>, void>
+ : mpl::true_
+ {};
+
/// INTERNAL ONLY
template<typename T>
struct is_aggregate<T, typename T::proto_is_aggregate_>
@@ -162,67 +174,67 @@
: mpl::true_
{};
- namespace result_of
- {
- /// \brief A Boolean metafunction that indicates whether a given
- /// type \c T is a Proto expression type.
- ///
- /// If \c T has a nested type \c proto_is_expr_ that is a typedef
- /// for \c void, <tt>is_expr\<T\>::::value</tt> is \c true. (Note, this
- /// is the case for <tt>proto::expr\<\></tt>, any type that is derived
- /// from <tt>proto::extends\<\></tt> or that uses the
- /// <tt>BOOST_PROTO_BASIC_EXTENDS()</tt> macro.) Otherwise,
- /// <tt>is_expr\<T\>::::value</tt> is \c false.
- template<typename T, typename Void /* = void*/>
- struct is_expr
- : mpl::false_
- {};
+ /// \brief A Boolean metafunction that indicates whether a given
+ /// type \c T is a Proto expression type.
+ ///
+ /// If \c T has a nested type \c proto_is_expr_ that is a typedef
+ /// for \c void, <tt>is_expr\<T\>::value</tt> is \c true. (Note, this
+ /// is the case for <tt>proto::expr\<\></tt>, any type that is derived
+ /// from <tt>proto::extends\<\></tt> or that uses the
+ /// <tt>BOOST_PROTO_BASIC_EXTENDS()</tt> macro.) Otherwise,
+ /// <tt>is_expr\<T\>::value</tt> is \c false.
+ template<typename T, typename Void /* = void*/>
+ struct is_expr
+ : mpl::false_
+ {};
- /// \brief A Boolean metafunction that indicates whether a given
- /// type \c T is a Proto expression type.
- ///
- /// If \c T has a nested type \c proto_is_expr_ that is a typedef
- /// for \c void, <tt>is_expr\<T\>::::value</tt> is \c true. (Note, this
- /// is the case for <tt>proto::expr\<\></tt>, any type that is derived
- /// from <tt>proto::extends\<\></tt> or that uses the
- /// <tt>BOOST_PROTO_BASIC_EXTENDS()</tt> macro.) Otherwise,
- /// <tt>is_expr\<T\>::::value</tt> is \c false.
- template<typename T>
- struct is_expr<T, typename T::proto_is_expr_>
- : mpl::true_
- {};
+ /// \brief A Boolean metafunction that indicates whether a given
+ /// type \c T is a Proto expression type.
+ ///
+ /// If \c T has a nested type \c proto_is_expr_ that is a typedef
+ /// for \c void, <tt>is_expr\<T\>::value</tt> is \c true. (Note, this
+ /// is the case for <tt>proto::expr\<\></tt>, any type that is derived
+ /// from <tt>proto::extends\<\></tt> or that uses the
+ /// <tt>BOOST_PROTO_BASIC_EXTENDS()</tt> macro.) Otherwise,
+ /// <tt>is_expr\<T\>::value</tt> is \c false.
+ template<typename T>
+ struct is_expr<T, typename T::proto_is_expr_>
+ : mpl::true_
+ {};
- template<typename T>
- struct is_expr<T &, void>
- : is_expr<T>
- {};
+ template<typename T>
+ struct is_expr<T &, void>
+ : is_expr<T>
+ {};
- /// \brief A metafunction that returns the tag type of a
- /// Proto expression.
- template<typename Expr>
- struct tag_of
- {
- typedef typename Expr::proto_tag type;
- };
+ /// \brief A metafunction that returns the tag type of a
+ /// Proto expression.
+ template<typename Expr>
+ struct tag_of
+ {
+ typedef typename Expr::proto_tag type;
+ };
- template<typename Expr>
- struct tag_of<Expr &>
- {
- typedef typename Expr::proto_tag type;
- };
+ template<typename Expr>
+ struct tag_of<Expr &>
+ {
+ typedef typename Expr::proto_tag type;
+ };
- /// \brief A metafunction that returns the arity of a
- /// Proto expression.
- template<typename Expr>
- struct arity_of
- : Expr::proto_arity
- {};
+ /// \brief A metafunction that returns the arity of a
+ /// Proto expression.
+ template<typename Expr>
+ struct arity_of
+ : Expr::proto_arity
+ {};
- template<typename Expr>
- struct arity_of<Expr &>
- : Expr::proto_arity
- {};
+ template<typename Expr>
+ struct arity_of<Expr &>
+ : Expr::proto_arity
+ {};
+ namespace result_of
+ {
/// \brief A metafunction that computes the return type of the \c as_expr()
/// function.
///
@@ -235,8 +247,8 @@
///
/// If \c T is a function type, let \c A be <tt>T &</tt>.
/// Otherwise, let \c A be the type \c T stripped of cv-qualifiers.
- /// Then, the result type <tt>as_expr\<T, Domain\>::::type</tt> is
- /// <tt>boost::result_of\<Domain(expr\< tag::terminal, term\<A\> \>)\>::::type</tt>.
+ /// Then, the result type <tt>as_expr\<T, Domain\>::type</tt> is
+ /// <tt>boost::result_of\<Domain(expr\< tag::terminal, term\<A\> \>)\>::type</tt>.
template<
typename T
, typename Domain // = default_domain
@@ -254,7 +266,7 @@
, remove_cv<T>
>::type
arg0_;
- typedef proto::expr<proto::tag::terminal, term<arg0_>, 0> expr_;
+ typedef typename base_expr<Domain, proto::tag::terminal, term<arg0_> >::type expr_;
typedef typename Domain::proto_generator proto_generator;
typedef typename proto_generator::template result<Domain(expr_)>::type type;
typedef type const reference;
@@ -264,7 +276,7 @@
template<typename T2>
static reference call(T2 &t)
{
- return proto_generator()(expr_::make(t));
+ return proto_generator()(expr_::make(static_cast<T &>(t)));
}
};
@@ -276,7 +288,7 @@
/// possible. Types which are already Proto types are left alone.
///
/// This specialization is selected when the type is already a Proto type.
- /// The result type <tt>as_expr\<T, Domain\>::::type</tt> is \c T stripped
+ /// The result type <tt>as_expr\<T, Domain\>::type</tt> is \c T stripped
/// of cv-qualifiers.
template<typename T, typename Domain>
struct as_expr<
@@ -298,7 +310,7 @@
template<typename T2>
static reference call(T2 &t)
{
- return proto_generator()(t);
+ return proto_generator()(static_cast<T &>(t));
}
};
@@ -318,7 +330,7 @@
/// INTERNAL ONLY
///
template<typename T2>
- static T2 &call(T2 &t)
+ static reference call(T2 &t)
{
return t;
}
@@ -332,8 +344,8 @@
/// Types which are already Proto types are returned by reference.
///
/// This specialization is selected when the type is not yet a Proto type.
- /// The result type <tt>as_child\<T, Domain\>::::type</tt> is
- /// <tt>boost::result_of\<Domain(expr\< tag::terminal, term\<T &\> \>)\>::::type</tt>.
+ /// The result type <tt>as_child\<T, Domain\>::type</tt> is
+ /// <tt>boost::result_of\<Domain(expr\< tag::terminal, term\<T &\> \>)\>::type</tt>.
template<
typename T
, typename Domain // = default_domain
@@ -344,7 +356,7 @@
>
struct as_child
{
- typedef proto::expr<proto::tag::terminal, term<T &>, 0> expr_;
+ typedef typename base_expr<Domain, proto::tag::terminal, term<T &> >::type expr_;
typedef typename Domain::proto_generator proto_generator;
typedef typename proto_generator::template result<proto_generator(expr_)>::type type;
@@ -353,7 +365,7 @@
template<typename T2>
static type call(T2 &t)
{
- return proto_generator()(expr_::make(t));
+ return proto_generator()(expr_::make(static_cast<T &>(t)));
}
};
@@ -365,7 +377,7 @@
/// Types which are already Proto types are returned by reference.
///
/// This specialization is selected when the type is already a Proto type.
- /// The result type <tt>as_child\<T, Domain\>::::type</tt> is
+ /// The result type <tt>as_child\<T, Domain\>::type</tt> is
/// <tt>T &</tt>.
template<typename T, typename Domain>
struct as_child<
@@ -397,7 +409,7 @@
template<typename T2>
static type call(T2 &t)
{
- return proto_generator()(t);
+ return proto_generator()(static_cast<T &>(t));
}
};
@@ -409,7 +421,7 @@
/// Types which are already Proto types are returned by reference.
///
/// This specialization is selected when the type is already a Proto type.
- /// The result type <tt>as_child\<T, Domain\>::::type</tt> is
+ /// The result type <tt>as_child\<T, Domain\>::type</tt> is
/// <tt>T &</tt>.
template<typename T>
struct as_child<
@@ -426,9 +438,9 @@
/// INTERNAL ONLY
///
template<typename T2>
- static T2 &call(T2 &t)
+ static type call(T2 &t)
{
- return t;
+ return static_cast<T &>(t);
}
};
@@ -528,258 +540,254 @@
} // namespace result_of
- namespace op
+ /// \brief A metafunction for generating terminal expression types,
+ /// a grammar element for matching terminal expressions, and a
+ /// PrimitiveTransform that returns the current expression unchanged.
+ template<typename T>
+ struct terminal
+ : proto::transform<terminal<T>, int>
{
- /// \brief A metafunction for generating terminal expression types,
- /// a grammar element for matching terminal expressions, and a
- /// PrimitiveTransform that returns the current expression unchanged.
- template<typename T>
- struct terminal
- : proto::transform<terminal<T>, int>
- {
- typedef proto::expr<proto::tag::terminal, term<T>, 0> type;
- typedef type proto_base_expr;
-
- template<typename Expr, typename State, typename Data>
- struct impl : transform_impl<Expr, State, Data>
- {
- typedef Expr result_type;
-
- /// \param e The current expression
- /// \pre <tt>matches\<Expr, terminal\<T\> \>::::value</tt> is \c true.
- /// \return \c e
- /// \throw nothrow
- #ifdef BOOST_PROTO_STRICT_RESULT_OF
- result_type
- #else
- typename impl::expr_param
- #endif
- operator ()(
- typename impl::expr_param e
- , typename impl::state_param
- , typename impl::data_param
- ) const
- {
- return e;
- }
- };
-
- /// INTERNAL ONLY
- typedef proto::tag::terminal proto_tag;
- /// INTERNAL ONLY
- typedef T proto_child0;
- };
-
- /// \brief A metafunction for generating ternary conditional expression types,
- /// a grammar element for matching ternary conditional expressions, and a
- /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
- /// transform.
- template<typename T, typename U, typename V>
- struct if_else_
- : proto::transform<if_else_<T, U, V>, int>
- {
- typedef proto::expr<proto::tag::if_else_, list3<T, U, V>, 3> type;
- typedef type proto_base_expr;
-
- template<typename Expr, typename State, typename Data>
- struct impl
- : detail::pass_through_impl<if_else_, Expr, State, Data>
- {};
-
- /// INTERNAL ONLY
- typedef proto::tag::if_else_ proto_tag;
- /// INTERNAL ONLY
- typedef T proto_child0;
- /// INTERNAL ONLY
- typedef U proto_child1;
- /// INTERNAL ONLY
- typedef V proto_child2;
- };
+ typedef proto::expr<proto::tag::terminal, term<T>, 0> type;
+ typedef proto::basic_expr<proto::tag::terminal, term<T>, 0> proto_grammar;
- /// \brief A metafunction for generating nullary expression types with a
- /// specified tag type,
- /// a grammar element for matching nullary expressions, and a
- /// PrimitiveTransform that returns the current expression unchanged.
- ///
- /// Use <tt>nullary_expr\<_, _\></tt> as a grammar element to match any
- /// nullary expression.
- template<typename Tag, typename T>
- struct nullary_expr
- : proto::transform<nullary_expr<Tag, T>, int>
- {
- typedef proto::expr<Tag, term<T>, 0> type;
- typedef type proto_base_expr;
-
- template<typename Expr, typename State, typename Data>
- struct impl : transform_impl<Expr, State, Data>
- {
- typedef Expr result_type;
-
- /// \param e The current expression
- /// \pre <tt>matches\<Expr, nullary_expr\<Tag, T\> \>::::value</tt> is \c true.
- /// \return \c e
- /// \throw nothrow
- #ifdef BOOST_PROTO_STRICT_RESULT_OF
- result_type
- #else
- typename impl::expr_param
- #endif
- operator ()(
- typename impl::expr_param e
- , typename impl::state_param
- , typename impl::data_param
- ) const
- {
- return e;
- }
- };
+ template<typename Expr, typename State, typename Data>
+ struct impl : transform_impl<Expr, State, Data>
+ {
+ typedef Expr result_type;
- /// INTERNAL ONLY
- typedef Tag proto_tag;
- /// INTERNAL ONLY
- typedef T proto_child0;
+ /// \param e The current expression
+ /// \pre <tt>matches\<Expr, terminal\<T\> \>::value</tt> is \c true.
+ /// \return \c e
+ /// \throw nothrow
+ #ifdef BOOST_PROTO_STRICT_RESULT_OF
+ result_type
+ #else
+ typename impl::expr_param
+ #endif
+ operator ()(
+ typename impl::expr_param e
+ , typename impl::state_param
+ , typename impl::data_param
+ ) const
+ {
+ return e;
+ }
};
- /// \brief A metafunction for generating unary expression types with a
- /// specified tag type,
- /// a grammar element for matching unary expressions, and a
- /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
- /// transform.
- ///
- /// Use <tt>unary_expr\<_, _\></tt> as a grammar element to match any
- /// unary expression.
- template<typename Tag, typename T>
- struct unary_expr
- : proto::transform<unary_expr<Tag, T>, int>
- {
- typedef proto::expr<Tag, list1<T>, 1> type;
- typedef type proto_base_expr;
-
- template<typename Expr, typename State, typename Data>
- struct impl
- : detail::pass_through_impl<unary_expr, Expr, State, Data>
- {};
+ /// INTERNAL ONLY
+ typedef proto::tag::terminal proto_tag;
+ /// INTERNAL ONLY
+ typedef T proto_child0;
+ };
+
+ /// \brief A metafunction for generating ternary conditional expression types,
+ /// a grammar element for matching ternary conditional expressions, and a
+ /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
+ /// transform.
+ template<typename T, typename U, typename V>
+ struct if_else_
+ : proto::transform<if_else_<T, U, V>, int>
+ {
+ typedef proto::expr<proto::tag::if_else_, list3<T, U, V>, 3> type;
+ typedef proto::basic_expr<proto::tag::if_else_, list3<T, U, V>, 3> proto_grammar;
+
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : detail::pass_through_impl<if_else_, Expr, State, Data>
+ {};
- /// INTERNAL ONLY
- typedef Tag proto_tag;
- /// INTERNAL ONLY
- typedef T proto_child0;
+ /// INTERNAL ONLY
+ typedef proto::tag::if_else_ proto_tag;
+ /// INTERNAL ONLY
+ typedef T proto_child0;
+ /// INTERNAL ONLY
+ typedef U proto_child1;
+ /// INTERNAL ONLY
+ typedef V proto_child2;
+ };
+
+ /// \brief A metafunction for generating nullary expression types with a
+ /// specified tag type,
+ /// a grammar element for matching nullary expressions, and a
+ /// PrimitiveTransform that returns the current expression unchanged.
+ ///
+ /// Use <tt>nullary_expr\<_, _\></tt> as a grammar element to match any
+ /// nullary expression.
+ template<typename Tag, typename T>
+ struct nullary_expr
+ : proto::transform<nullary_expr<Tag, T>, int>
+ {
+ typedef proto::expr<Tag, term<T>, 0> type;
+ typedef proto::basic_expr<Tag, term<T>, 0> proto_grammar;
+
+ template<typename Expr, typename State, typename Data>
+ struct impl : transform_impl<Expr, State, Data>
+ {
+ typedef Expr result_type;
+
+ /// \param e The current expression
+ /// \pre <tt>matches\<Expr, nullary_expr\<Tag, T\> \>::value</tt> is \c true.
+ /// \return \c e
+ /// \throw nothrow
+ #ifdef BOOST_PROTO_STRICT_RESULT_OF
+ result_type
+ #else
+ typename impl::expr_param
+ #endif
+ operator ()(
+ typename impl::expr_param e
+ , typename impl::state_param
+ , typename impl::data_param
+ ) const
+ {
+ return e;
+ }
};
- /// \brief A metafunction for generating binary expression types with a
- /// specified tag type,
- /// a grammar element for matching binary expressions, and a
- /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
- /// transform.
- ///
- /// Use <tt>binary_expr\<_, _, _\></tt> as a grammar element to match any
- /// binary expression.
- template<typename Tag, typename T, typename U>
- struct binary_expr
- : proto::transform<binary_expr<Tag, T, U>, int>
- {
- typedef proto::expr<Tag, list2<T, U>, 2> type;
- typedef type proto_base_expr;
-
- template<typename Expr, typename State, typename Data>
- struct impl
- : detail::pass_through_impl<binary_expr, Expr, State, Data>
- {};
+ /// INTERNAL ONLY
+ typedef Tag proto_tag;
+ /// INTERNAL ONLY
+ typedef T proto_child0;
+ };
+
+ /// \brief A metafunction for generating unary expression types with a
+ /// specified tag type,
+ /// a grammar element for matching unary expressions, and a
+ /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
+ /// transform.
+ ///
+ /// Use <tt>unary_expr\<_, _\></tt> as a grammar element to match any
+ /// unary expression.
+ template<typename Tag, typename T>
+ struct unary_expr
+ : proto::transform<unary_expr<Tag, T>, int>
+ {
+ typedef proto::expr<Tag, list1<T>, 1> type;
+ typedef proto::basic_expr<Tag, list1<T>, 1> proto_grammar;
+
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : detail::pass_through_impl<unary_expr, Expr, State, Data>
+ {};
- /// INTERNAL ONLY
- typedef Tag proto_tag;
- /// INTERNAL ONLY
- typedef T proto_child0;
- /// INTERNAL ONLY
- typedef U proto_child1;
- };
+ /// INTERNAL ONLY
+ typedef Tag proto_tag;
+ /// INTERNAL ONLY
+ typedef T proto_child0;
+ };
+
+ /// \brief A metafunction for generating binary expression types with a
+ /// specified tag type,
+ /// a grammar element for matching binary expressions, and a
+ /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
+ /// transform.
+ ///
+ /// Use <tt>binary_expr\<_, _, _\></tt> as a grammar element to match any
+ /// binary expression.
+ template<typename Tag, typename T, typename U>
+ struct binary_expr
+ : proto::transform<binary_expr<Tag, T, U>, int>
+ {
+ typedef proto::expr<Tag, list2<T, U>, 2> type;
+ typedef proto::basic_expr<Tag, list2<T, U>, 2> proto_grammar;
+
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : detail::pass_through_impl<binary_expr, Expr, State, Data>
+ {};
- #define BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(Op) \
- template<typename T> \
- struct Op \
- : proto::transform<Op<T>, int> \
- { \
- typedef proto::expr<proto::tag::Op, list1<T>, 1> type; \
- typedef type proto_base_expr; \
+ /// INTERNAL ONLY
+ typedef Tag proto_tag;
+ /// INTERNAL ONLY
+ typedef T proto_child0;
+ /// INTERNAL ONLY
+ typedef U proto_child1;
+ };
+
+ #define BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(Op) \
+ template<typename T> \
+ struct Op \
+ : proto::transform<Op<T>, int> \
+ { \
+ typedef proto::expr<proto::tag::Op, list1<T>, 1> type; \
+ typedef proto::basic_expr<proto::tag::Op, list1<T>, 1> proto_grammar; \
\
- template<typename Expr, typename State, typename Data> \
- struct impl \
- : detail::pass_through_impl<Op, Expr, State, Data> \
- {}; \
+ template<typename Expr, typename State, typename Data> \
+ struct impl \
+ : detail::pass_through_impl<Op, Expr, State, Data> \
+ {}; \
\
- typedef proto::tag::Op proto_tag; \
- typedef T proto_child0; \
- }; \
- /**/
-
- #define BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(Op) \
- template<typename T, typename U> \
- struct Op \
- : proto::transform<Op<T, U>, int> \
- { \
- typedef proto::expr<proto::tag::Op, list2<T, U>, 2> type; \
- typedef type proto_base_expr; \
+ typedef proto::tag::Op proto_tag; \
+ typedef T proto_child0; \
+ }; \
+ /**/
+
+ #define BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(Op) \
+ template<typename T, typename U> \
+ struct Op \
+ : proto::transform<Op<T, U>, int> \
+ { \
+ typedef proto::expr<proto::tag::Op, list2<T, U>, 2> type; \
+ typedef proto::basic_expr<proto::tag::Op, list2<T, U>, 2> proto_grammar; \
\
- template<typename Expr, typename State, typename Data> \
- struct impl \
- : detail::pass_through_impl<Op, Expr, State, Data> \
- {}; \
+ template<typename Expr, typename State, typename Data> \
+ struct impl \
+ : detail::pass_through_impl<Op, Expr, State, Data> \
+ {}; \
\
- typedef proto::tag::Op proto_tag; \
- typedef T proto_child0; \
- typedef U proto_child1; \
- }; \
- /**/
-
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(unary_plus)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(negate)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(dereference)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(complement)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(address_of)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(logical_not)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(pre_inc)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(pre_dec)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(post_inc)
- BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(post_dec)
-
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_left)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_right)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(multiplies)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(divides)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(modulus)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(plus)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(minus)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(less)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(greater)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(less_equal)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(greater_equal)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(equal_to)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(not_equal_to)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(logical_or)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(logical_and)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_or)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_and)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_xor)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(comma)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(mem_ptr)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_left_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_right_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(multiplies_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(divides_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(modulus_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(plus_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(minus_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_or_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_and_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_xor_assign)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(subscript)
- BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(member)
+ typedef proto::tag::Op proto_tag; \
+ typedef T proto_child0; \
+ typedef U proto_child1; \
+ }; \
+ /**/
- #undef BOOST_PROTO_DEFINE_UNARY_METAFUNCTION
- #undef BOOST_PROTO_DEFINE_BINARY_METAFUNCTION
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(unary_plus)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(negate)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(dereference)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(complement)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(address_of)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(logical_not)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(pre_inc)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(pre_dec)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(post_inc)
+ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(post_dec)
+
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_left)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_right)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(multiplies)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(divides)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(modulus)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(plus)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(minus)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(less)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(greater)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(less_equal)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(greater_equal)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(equal_to)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(not_equal_to)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(logical_or)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(logical_and)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_or)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_and)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_xor)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(comma)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(mem_ptr)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_left_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_right_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(multiplies_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(divides_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(modulus_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(plus_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(minus_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_or_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_and_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_xor_assign)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(subscript)
+ BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(member)
- } // namespace op
+ #undef BOOST_PROTO_DEFINE_UNARY_METAFUNCTION
+ #undef BOOST_PROTO_DEFINE_BINARY_METAFUNCTION
#define BOOST_PROTO_CHILD(Z, N, DATA) \
/** INTERNAL ONLY */ \
@@ -806,10 +814,13 @@
template<typename This, typename T>
struct result<This(T)>
- {
- typedef typename remove_reference<T>::type unref_type;
- typedef typename result_of::as_expr<unref_type, Domain>::type type;
- };
+ : result_of::as_expr<T, Domain>
+ {};
+
+ template<typename This, typename T>
+ struct result<This(T &)>
+ : result_of::as_expr<T, Domain>
+ {};
/// \brief Wrap an object in a Proto terminal if it isn't a
/// Proto expression already.
@@ -860,10 +871,13 @@
template<typename This, typename T>
struct result<This(T)>
- {
- typedef typename remove_reference<T>::type unref_type;
- typedef typename result_of::as_child<unref_type, Domain>::type type;
- };
+ : result_of::as_child<T, Domain>
+ {};
+
+ template<typename This, typename T>
+ struct result<This(T &)>
+ : result_of::as_child<T, Domain>
+ {};
/// \brief Wrap an object in a Proto terminal if it isn't a
/// Proto expression already.
@@ -904,7 +918,7 @@
/// \brief Return the Nth child of the given expression.
/// \param expr The expression node.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true
/// \pre <tt>N \< Expr::proto_arity::value</tt>
/// \return <tt>proto::child_c\<N\>(expr)</tt>
/// \throw nothrow
@@ -947,7 +961,7 @@
/// \brief Return the Nth child of the given expression.
/// \param expr The expression node.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true
/// \pre <tt>N::value \< Expr::proto_arity::value</tt>
/// \return <tt>proto::child\<N\>(expr)</tt>
/// \throw nothrow
@@ -985,7 +999,7 @@
/// \brief Return the value of the given terminal expression.
/// \param expr The terminal expression node.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true
/// \pre <tt>0 == Expr::proto_arity::value</tt>
/// \return <tt>proto::value(expr)</tt>
/// \throw nothrow
@@ -1023,7 +1037,7 @@
/// \brief Return the left child of the given binary expression.
/// \param expr The expression node.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true
/// \pre <tt>2 == Expr::proto_arity::value</tt>
/// \return <tt>proto::left(expr)</tt>
/// \throw nothrow
@@ -1061,7 +1075,7 @@
/// \brief Return the right child of the given binary expression.
/// \param expr The expression node.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true
/// \pre <tt>2 == Expr::proto_arity::value</tt>
/// \return <tt>proto::right(expr)</tt>
/// \throw nothrow
@@ -1095,12 +1109,12 @@
/// without (i.e., <tt>as_expr(t)</tt>). If no domain is
/// specified, \c default_domain is assumed.
///
- /// If <tt>is_expr\<T\>::::value</tt> is \c true, then the argument is
+ /// If <tt>is_expr\<T\>::value</tt> is \c true, then the argument is
/// returned unmodified, by reference. Otherwise, the argument is wrapped
/// in a Proto terminal expression node according to the following rules.
/// If \c T is a function type, let \c A be <tt>T &</tt>. Otherwise, let
/// \c A be the type \c T stripped of cv-qualifiers. Then, \c as_expr()
- /// returns <tt>Domain()(terminal\<A\>::::type::make(t))</tt>.
+ /// returns <tt>Domain()(terminal\<A\>::type::make(t))</tt>.
///
/// \param t The object to wrap.
template<typename T>
@@ -1151,9 +1165,9 @@
/// without (i.e., <tt>as_child(t)</tt>). If no domain is
/// specified, \c default_domain is assumed.
///
- /// If <tt>is_expr\<T\>::::value</tt> is \c true, then the argument is
+ /// If <tt>is_expr\<T\>::value</tt> is \c true, then the argument is
/// returned as-is. Otherwise, \c as_child() returns
- /// <tt>Domain()(terminal\<T &\>::::type::make(t))</tt>.
+ /// <tt>Domain()(terminal\<T &\>::type::make(t))</tt>.
///
/// \param t The object to wrap.
template<typename T>
@@ -1198,7 +1212,7 @@
/// reference.
///
/// \param expr The Proto expression.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true.
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true.
/// \pre \c N is an MPL Integral Constant.
/// \pre <tt>N::value \< Expr::proto_arity::value</tt>
/// \throw nothrow
@@ -1243,7 +1257,7 @@
/// is returned by reference.
///
/// \param expr The Proto expression.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true.
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true.
/// \pre <tt>N \< Expr::proto_arity::value</tt>
/// \throw nothrow
/// \return A reference to the Nth child
@@ -1297,7 +1311,7 @@
/// child is returned by reference.
///
/// \param expr The Proto expression.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true.
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true.
/// \pre <tt>2 == Expr::proto_arity::value</tt>
/// \throw nothrow
/// \return A reference to the left child
@@ -1324,7 +1338,7 @@
/// child is returned by reference.
///
/// \param expr The Proto expression.
- /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true.
+ /// \pre <tt>is_expr\<Expr\>::value</tt> is \c true.
/// \pre <tt>2 == Expr::proto_arity::value</tt>
/// \throw nothrow
/// \return A reference to the right child
@@ -1384,93 +1398,89 @@
#define N BOOST_PP_ITERATION()
#if N > 0
- namespace op
- {
- /// \brief A metafunction for generating function-call expression types,
- /// a grammar element for matching function-call expressions, and a
- /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
- /// transform.
- template<BOOST_PP_ENUM_PARAMS(N, typename A)>
- struct function
- #if N != BOOST_PROTO_MAX_ARITY
- <
- BOOST_PP_ENUM_PARAMS(N, A)
- BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
- >
- #endif
- : proto::transform<
- function<
- BOOST_PP_ENUM_PARAMS(N, A)
- BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
- >
- , int
+ /// \brief A metafunction for generating function-call expression types,
+ /// a grammar element for matching function-call expressions, and a
+ /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
+ /// transform.
+ template<BOOST_PP_ENUM_PARAMS(N, typename A)>
+ struct function
+ #if N != BOOST_PROTO_MAX_ARITY
+ <
+ BOOST_PP_ENUM_PARAMS(N, A)
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
+ >
+ #endif
+ : proto::transform<
+ function<
+ BOOST_PP_ENUM_PARAMS(N, A)
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
>
- {
- typedef proto::expr<proto::tag::function, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> type;
- typedef type proto_base_expr;
-
- template<typename Expr, typename State, typename Data>
- struct impl
- : detail::pass_through_impl<function, Expr, State, Data>
- {};
+ , int
+ >
+ {
+ typedef proto::expr<proto::tag::function, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> type;
+ typedef proto::basic_expr<proto::tag::function, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> proto_grammar;
- /// INTERNAL ONLY
- typedef proto::tag::function proto_tag;
- BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A)
- BOOST_PP_REPEAT_FROM_TO(
- N
- , BOOST_PROTO_MAX_ARITY
- , BOOST_PROTO_CHILD
- , detail::if_vararg<BOOST_PP_CAT(A, BOOST_PP_DEC(N))> BOOST_PP_INTERCEPT
- )
- };
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : detail::pass_through_impl<function, Expr, State, Data>
+ {};
- /// \brief A metafunction for generating n-ary expression types with a
- /// specified tag type,
- /// a grammar element for matching n-ary expressions, and a
- /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
- /// transform.
- ///
- /// Use <tt>nary_expr\<_, vararg\<_\> \></tt> as a grammar element to match any
- /// n-ary expression; that is, any non-terminal.
- template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
- struct nary_expr
- #if N != BOOST_PROTO_MAX_ARITY
- <
- Tag
- BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
- BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
- >
- #endif
- : proto::transform<
- nary_expr<
- Tag
- BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
- BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
- >
- , int
+ /// INTERNAL ONLY
+ typedef proto::tag::function proto_tag;
+ BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A)
+ BOOST_PP_REPEAT_FROM_TO(
+ N
+ , BOOST_PROTO_MAX_ARITY
+ , BOOST_PROTO_CHILD
+ , detail::if_vararg<BOOST_PP_CAT(A, BOOST_PP_DEC(N))> BOOST_PP_INTERCEPT
+ )
+ };
+
+ /// \brief A metafunction for generating n-ary expression types with a
+ /// specified tag type,
+ /// a grammar element for matching n-ary expressions, and a
+ /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
+ /// transform.
+ ///
+ /// Use <tt>nary_expr\<_, vararg\<_\> \></tt> as a grammar element to match any
+ /// n-ary expression; that is, any non-terminal.
+ template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct nary_expr
+ #if N != BOOST_PROTO_MAX_ARITY
+ <
+ Tag
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
+ >
+ #endif
+ : proto::transform<
+ nary_expr<
+ Tag
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
>
- {
- typedef proto::expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> type;
- typedef type proto_base_expr;
-
- template<typename Expr, typename State, typename Data>
- struct impl
- : detail::pass_through_impl<nary_expr, Expr, State, Data>
- {};
+ , int
+ >
+ {
+ typedef proto::expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> type;
+ typedef proto::basic_expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> proto_grammar;
- /// INTERNAL ONLY
- typedef Tag proto_tag;
- BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A)
- BOOST_PP_REPEAT_FROM_TO(
- N
- , BOOST_PROTO_MAX_ARITY
- , BOOST_PROTO_CHILD
- , detail::if_vararg<BOOST_PP_CAT(A, BOOST_PP_DEC(N))> BOOST_PP_INTERCEPT
- )
- };
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : detail::pass_through_impl<nary_expr, Expr, State, Data>
+ {};
- } // namespace op
+ /// INTERNAL ONLY
+ typedef Tag proto_tag;
+ BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A)
+ BOOST_PP_REPEAT_FROM_TO(
+ N
+ , BOOST_PROTO_MAX_ARITY
+ , BOOST_PROTO_CHILD
+ , detail::if_vararg<BOOST_PP_CAT(A, BOOST_PP_DEC(N))> BOOST_PP_INTERCEPT
+ )
+ };
namespace detail
{
Modified: branches/release/boost/proto/transform/arg.hpp
==============================================================================
--- branches/release/boost/proto/transform/arg.hpp (original)
+++ branches/release/boost/proto/transform/arg.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -150,7 +150,7 @@
result_type;
/// Returns the N-th child of \c e
- /// \pre <tt>arity_of\<Expr\>::::value \> N</tt>
+ /// \pre <tt>arity_of\<Expr\>::value \> N</tt>
/// \param e The current expression.
/// \return <tt>proto::child_c\<N\>(e)</tt>
/// \throw nothrow
@@ -190,7 +190,7 @@
result_type;
/// Returns the value of the specified terminal expression.
- /// \pre <tt>arity_of\<Expr\>::::value == 0</tt>.
+ /// \pre <tt>arity_of\<Expr\>::value == 0</tt>.
/// \param e The current expression.
/// \return <tt>proto::value(e)</tt>
/// \throw nothrow
Modified: branches/release/boost/proto/transform/call.hpp
==============================================================================
--- branches/release/boost/proto/transform/call.hpp (original)
+++ branches/release/boost/proto/transform/call.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -121,8 +121,8 @@
/// \param d An arbitrary data
/// If \c Fun is a nullary PolymorphicFunctionObject, \c type is a typedef
- /// for <tt>boost::result_of\<Fun()\>::::type</tt>. Otherwise, it is
- /// a typedef for <tt>boost::result_of\<Fun(Expr, State, Data)\>::::type</tt>.
+ /// for <tt>boost::result_of\<Fun()\>::type</tt>. Otherwise, it is
+ /// a typedef for <tt>boost::result_of\<Fun(Expr, State, Data)\>::type</tt>.
template<typename Expr, typename State, typename Data>
struct impl
: impl2<Expr, State, Data, is_transform<Fun>::value>
@@ -175,8 +175,8 @@
/// Let \c x be <tt>when\<_, A0\>()(e, s, d)</tt> and \c X
/// be the type of \c x.
/// If \c Fun is a unary PolymorphicFunctionObject that accepts \c x,
- /// then \c type is a typedef for <tt>boost::result_of\<Fun(X)\>::::type</tt>.
- /// Otherwise, it is a typedef for <tt>boost::result_of\<Fun(X, State, Data)\>::::type</tt>.
+ /// then \c type is a typedef for <tt>boost::result_of\<Fun(X)\>::type</tt>.
+ /// Otherwise, it is a typedef for <tt>boost::result_of\<Fun(X, State, Data)\>::type</tt>.
/// Either call the PolymorphicFunctionObject with 1 argument:
/// the result of applying the \c A0 transform; or
@@ -251,8 +251,8 @@
/// be the type of \c y.
/// If \c Fun is a binary PolymorphicFunction object that accepts \c x
/// and \c y, then \c type is a typedef for
- /// <tt>boost::result_of\<Fun(X, Y)\>::::type</tt>. Otherwise, it is
- /// a typedef for <tt>boost::result_of\<Fun(X, Y, Data)\>::::type</tt>.
+ /// <tt>boost::result_of\<Fun(X, Y)\>::type</tt>. Otherwise, it is
+ /// a typedef for <tt>boost::result_of\<Fun(X, Y, Data)\>::type</tt>.
/// Either call the PolymorphicFunctionObject with 2 arguments:
/// the result of applying the \c A0 transform, and the
Modified: branches/release/boost/proto/transform/make.hpp
==============================================================================
--- branches/release/boost/proto/transform/make.hpp (original)
+++ branches/release/boost/proto/transform/make.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -89,6 +89,14 @@
typedef proto::expr<Tag, Args, N> type;
typedef void not_applied_;
};
+
+ // work around GCC bug
+ template<typename Tag, typename Args, long N, typename Expr, typename State, typename Data>
+ struct make_if_<proto::basic_expr<Tag, Args, N>, Expr, State, Data, false>
+ {
+ typedef proto::basic_expr<Tag, Args, N> type;
+ typedef void not_applied_;
+ };
#endif
// TODO could optimize this if R is a transform
@@ -207,23 +215,23 @@
///
/// \li Function types
/// \li Function pointer types
- /// \li Types for which <tt>proto::is_callable\< type \>::::value</tt> is \c true
+ /// \li Types for which <tt>proto::is_callable\< type \>::value</tt> is \c true
///
- /// <tt>boost::result_of\<make\<T\<X0,X1,...\> \>(Expr, State, Data)\>::::type</tt>
+ /// <tt>boost::result_of\<make\<T\<X0,X1,...\> \>(Expr, State, Data)\>::type</tt>
/// is evaluated as follows. For each \c X in <tt>X0,X1,...</tt>, do:
///
/// \li If \c X is a template like <tt>U\<Y0,Y1,...\></tt>, then let <tt>X'</tt>
- /// be <tt>boost::result_of\<make\<U\<Y0,Y1,...\> \>(Expr, State, Data)\>::::type</tt>
+ /// be <tt>boost::result_of\<make\<U\<Y0,Y1,...\> \>(Expr, State, Data)\>::type</tt>
/// (which evaluates this procedure recursively). Note whether any
/// substitutions took place during this operation.
/// \li Otherwise, if \c X is a transform, then let <tt>X'</tt> be
- /// <tt>boost::result_of\<when\<_, X\>(Expr, State, Data)\>::::type</tt>.
+ /// <tt>boost::result_of\<when\<_, X\>(Expr, State, Data)\>::type</tt>.
/// Note that a substitution took place.
/// \li Otherwise, let <tt>X'</tt> be \c X, and note that no substitution
/// took place.
/// \li If any substitutions took place in any of the above steps and
/// <tt>T\<X0',X1',...\></tt> has a nested <tt>::type</tt> typedef,
- /// the result type is <tt>T\<X0',X1',...\>::::type</tt>.
+ /// the result type is <tt>T\<X0',X1',...\>::type</tt>.
/// \li Otherwise, the result type is <tt>T\<X0',X1',...\></tt>.
///
/// Note that <tt>when\<\></tt> is implemented in terms of <tt>call\<\></tt>
@@ -362,6 +370,18 @@
return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
}
};
+
+ template<typename T, typename A>
+ struct construct_<proto::basic_expr<T, A, N>, true>
+ {
+ typedef proto::basic_expr<T, A, N> result_type;
+
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), typename A)>
+ result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const
+ {
+ return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
+ }
+ };
}
/// \brief A PrimitiveTransform which computes a type by evaluating any
@@ -375,7 +395,7 @@
template<typename Expr, typename State, typename Data>
struct impl : transform_impl<Expr, State, Data>
{
- /// \brief <tt>boost::result_of\<make\<Object\>(Expr, State, Data)\>::::type</tt>
+ /// \brief <tt>boost::result_of\<make\<Object\>(Expr, State, Data)\>::type</tt>
typedef typename detail::make_if_<Object, Expr, State, Data>::type result_type;
//typedef typename detail::make_<Object, Expr, State, Data>::type result_type;
@@ -437,6 +457,34 @@
}
};
};
+
+ template<typename Tag, typename Args, long Arity BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct make<proto::basic_expr<Tag, Args, Arity>(BOOST_PP_ENUM_PARAMS(N, A))>
+ : transform<make<proto::basic_expr<Tag, Args, Arity>(BOOST_PP_ENUM_PARAMS(N, A))> >
+ {
+ template<typename Expr, typename State, typename Data>
+ struct impl : transform_impl<Expr, State, Data>
+ {
+ typedef proto::basic_expr<Tag, Args, Arity> result_type;
+
+ result_type operator ()(
+ typename impl::expr_param e
+ , typename impl::state_param s
+ , typename impl::data_param d
+ ) const
+ {
+ return proto::basic_expr<Tag, Args, Arity>::make(
+ #define TMP(Z, M, DATA) \
+ detail::as_lvalue( \
+ typename when<_, BOOST_PP_CAT(A, M)> \
+ ::template impl<Expr, State, Data>()(e, s, d) \
+ )
+ BOOST_PP_ENUM(N, TMP, DATA)
+ #undef TMP
+ );
+ }
+ };
+ };
#endif
#undef N
Modified: branches/release/boost/proto/transform/pass_through.hpp
==============================================================================
--- branches/release/boost/proto/transform/pass_through.hpp (original)
+++ branches/release/boost/proto/transform/pass_through.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -91,7 +91,7 @@
/// a Grammar.
///
/// Given a Grammar such as <tt>plus\<T0, T1\></tt>, an expression type
- /// that matches the grammar such as <tt>plus\<E0, E1\>::::type</tt>, a
+ /// that matches the grammar such as <tt>plus\<E0, E1\>::type</tt>, a
/// state \c S and a data \c V, the result of applying the
/// <tt>pass_through\<plus\<T0, T1\> \></tt> transform is:
///
@@ -167,13 +167,15 @@
{
typedef typename pass_through_impl::expr unref_expr;
- typedef proto::expr<
- typename unref_expr::proto_tag
- , BOOST_PP_CAT(list, N)<
- BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_TRANSFORM_TYPE, ~)
- >
- , N
- > expr_type;
+ typedef
+ typename base_expr<
+ typename unref_expr::proto_domain
+ , typename unref_expr::proto_tag
+ , BOOST_PP_CAT(list, N)<
+ BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_TRANSFORM_TYPE, ~)
+ >
+ >::type
+ expr_type;
typedef typename unref_expr::proto_generator proto_generator;
typedef typename boost::tr1_result_of<proto_generator(expr_type)>::type result_type;
Modified: branches/release/boost/proto/transform/when.hpp
==============================================================================
--- branches/release/boost/proto/transform/when.hpp (original)
+++ branches/release/boost/proto/transform/when.hpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -46,8 +46,8 @@
/// In <tt>when\<G, T\></tt>, when \c T is a class type it is a
/// PrimitiveTransform and the following equivalencies hold:
///
- /// <tt>boost::result_of\<when\<G,T\>(E,S,V)\>::::type</tt> is the same as
- /// <tt>boost::result_of\<T(E,S,V)\>::::type</tt>.
+ /// <tt>boost::result_of\<when\<G,T\>(E,S,V)\>::type</tt> is the same as
+ /// <tt>boost::result_of\<T(E,S,V)\>::type</tt>.
///
/// <tt>when\<G,T\>()(e,s,d)</tt> is the same as
/// <tt>T()(e,s,d)</tt>.
@@ -55,7 +55,7 @@
struct when
: PrimitiveTransform
{
- typedef typename Grammar::proto_base_expr proto_base_expr;
+ typedef typename Grammar::proto_grammar proto_grammar;
};
/// \brief A specialization that treats function pointer Transforms as
@@ -130,7 +130,7 @@
///
/// The <tt>when\<G, R(A0,A1,...)\></tt> form accepts either a
/// CallableTransform or an ObjectTransform as its second parameter.
- /// <tt>when\<\></tt> uses <tt>is_callable\<R\>::::value</tt> to
+ /// <tt>when\<\></tt> uses <tt>is_callable\<R\>::value</tt> to
/// distinguish between the two, and uses <tt>call\<\></tt> to
/// evaluate CallableTransforms and <tt>make\<\></tt> to evaluate
/// ObjectTransforms.
@@ -138,7 +138,7 @@
struct when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A))>
: transform<when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A))> >
{
- typedef typename Grammar::proto_base_expr proto_base_expr;
+ typedef typename Grammar::proto_grammar proto_grammar;
// Note: do not evaluate is_callable<R> in this scope.
// R may be an incomplete type at this point.
@@ -159,13 +159,13 @@
/// Evaluate <tt>R(A0,A1,...)</tt> as a transform either with
/// <tt>call\<\></tt> or with <tt>make\<\></tt> depending on
- /// whether <tt>is_callable\<R\>::::value</tt> is \c true or
+ /// whether <tt>is_callable\<R\>::value</tt> is \c true or
/// \c false.
///
/// \param e The current expression
/// \param s The current state
/// \param d An arbitrary data
- /// \pre <tt>matches\<Expr, Grammar\>::::value</tt> is \c true
+ /// \pre <tt>matches\<Expr, Grammar\>::value</tt> is \c true
/// \return <tt>which()(e, s, d)</tt>
result_type operator ()(
typename impl::expr_param e
Modified: branches/release/libs/proto/doc/glossary.qbk
==============================================================================
--- branches/release/libs/proto/doc/glossary.qbk (original)
+++ branches/release/libs/proto/doc/glossary.qbk 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -45,9 +45,9 @@
within that problem space.]]
[ [ [anchor expression] expression]
[In Proto, an /expression/ is a heterogeneous tree where each node is either
- an instantiation of `boost::proto::expr<>` or some type that is an extension
- (via `boost::proto::extends<>` or `BOOST_PROTO_EXTENDS()`) of such an
- instantiation.]]
+ an instantiation of `boost::proto::expr<>`, `boost::proto::basic_expr<>` or
+ some type that is an extension (via `boost::proto::extends<>` or
+ `BOOST_PROTO_EXTENDS()`) of such an instantiation.]]
[ [ [anchor expression_template] expression template]
[A C++ technique using templates and operator overloading to cause
expressions to build trees that represent the expression for lazy evaluation
Modified: branches/release/libs/proto/doc/proto.qbk
==============================================================================
--- branches/release/libs/proto/doc/proto.qbk (original)
+++ branches/release/libs/proto/doc/proto.qbk 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -47,6 +47,8 @@
[@../../libs/typeof/index.html Boost.Typeof]]
[def _expr_
[classref boost::proto::expr `proto::expr<>`]]
+[def _basic_expr_
+ [classref boost::proto::basic_expr `proto::basic_expr<>`]]
[def _deep_copy_
[funcref boost::proto::deep_copy `proto::deep_copy()`]]
[def _domain_
Modified: branches/release/libs/proto/doc/reference.xml
==============================================================================
--- branches/release/libs/proto/doc/reference.xml (original)
+++ branches/release/libs/proto/doc/reference.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -77,6 +77,16 @@
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::base_expr">proto::base_expr</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
+ <classname alt="boost::proto::basic_expr">proto::basic_expr</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::binary_expr">proto::binary_expr</classname>
</computeroutput>
</listitem>
@@ -912,6 +922,11 @@
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::use_basic_expr">proto::use_basic_expr</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::unexpr">proto::unexpr</classname>
</computeroutput>
</listitem>
@@ -922,6 +937,11 @@
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::wants_basic_expr">proto::wants_basic_expr</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::when">proto::when</classname>
</computeroutput>
</listitem>
Modified: branches/release/libs/proto/doc/reference/args.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/args.xml (original)
+++ branches/release/libs/proto/doc/reference/args.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -16,13 +16,16 @@
<template>
<template-type-parameter name="T"/>
</template>
- <purpose>A type sequence, for use as the 2<superscript>nd</superscript> parameter to the <computeroutput>
- <classname alt="proto::expr">proto::expr<></classname></computeroutput> class template.</purpose>
+ <purpose>A type sequence, for use as the 2<superscript>nd</superscript> parameter to the
+ <computeroutput><classname alt="proto::expr">proto::expr<></classname></computeroutput> and
+ <computeroutput><classname alt="proto::basic_expr">proto::basic_expr<></classname></computeroutput>
+ class templates.</purpose>
<description>
<para>
- A type sequence, for use as the 2<superscript>nd</superscript> parameter to the <computeroutput>
- <classname alt="proto::expr">proto::expr<></classname></computeroutput> class template. The
- types in the sequence correspond to the children of a node in an expression tree.
+ A type sequence with one element, for use as the 2<superscript>nd</superscript> parameter to the
+ <computeroutput><classname alt="proto::expr">proto::expr<></classname></computeroutput> and
+ <computeroutput><classname alt="proto::basic_expr">proto::basic_expr<></classname></computeroutput>
+ class templates. The sequence element represents the value of a terminal.
</para>
</description>
<data-member name="arity" specifiers="static">
@@ -40,12 +43,14 @@
<template-type-parameter name="Arg" pack="1"/>
</template>
<purpose><computeroutput>proto::list1<></computeroutput>, <computeroutput>proto::list2<></computeroutput>, etc.,
- are type sequences for use as the 2<superscript>nd</superscript> parameter to the <computeroutput>
- <classname>proto::expr<></classname></computeroutput> class template.</purpose>
+ are type sequences for use as the 2<superscript>nd</superscript> parameter to the
+ <computeroutput><classname>proto::expr<></classname></computeroutput> or
+ <computeroutput><classname>proto::basic_expr<></classname></computeroutput> class templates.</purpose>
<description>
<para>
- Type sequences, for use as the 2<superscript>nd</superscript> parameter to the <computeroutput>
- <classname>proto::expr<></classname></computeroutput> class template. The
+ Type sequences, for use as the 2<superscript>nd</superscript> parameter to the
+ <computeroutput><classname>proto::expr<></classname></computeroutput> or
+ <computeroutput><classname>proto::basic_expr<></classname></computeroutput> class template. The
types in the sequence correspond to the children of a node in an expression tree.
There is no type literally named "<computeroutput>listN</computeroutput>"; rather, there is
a set of types named
Modified: branches/release/libs/proto/doc/reference/concepts/Domain.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/concepts/Domain.xml (original)
+++ branches/release/libs/proto/doc/reference/concepts/Domain.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -63,6 +63,19 @@
</description>
</associated-type>
+ <associated-type name="proto_super_domain">
+ <get-member-type name="proto_super_domain">
+ <type name="Domain"/>
+ </get-member-type>
+ <description>
+ <simpara>
+ The Domain that is a super-domain of this domain, if
+ any such domain exists. If not, it is some unspecified
+ type.
+ </simpara>
+ </description>
+ </associated-type>
+
<associated-type name="result_type">
<get-member-type name="type">
<apply-template name="boost::result_of">
Modified: branches/release/libs/proto/doc/reference/concepts/Expr.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/concepts/Expr.xml (original)
+++ branches/release/libs/proto/doc/reference/concepts/Expr.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -72,6 +72,22 @@
</description>
</associated-type>
+ <associated-type name="proto_grammar">
+ <get-member-type name="proto_grammar">
+ <type name="Expr"/>
+ </get-member-type>
+ <description>
+ <simpara>
+ A typedef for an instantiation of
+ <classname alt="boost::proto::basic_expr">
+ <code>proto::basic_expr<></code>
+ </classname>
+ that is equivalent to Expr. Expression types are equivalent if they have the
+ same <code>proto_tag</code>, <code>proto_args</code>, and <code>proto_arity</code>.
+ </simpara>
+ </description>
+ </associated-type>
+
<associated-type name="proto_base_expr">
<get-member-type name="proto_base_expr">
<type name="Expr"/>
@@ -79,7 +95,8 @@
<description>
<simpara>
A typedef for an instantiation of
- <classname alt="boost::proto::expr"><code>proto::expr<></code></classname>
+ <classname alt="boost::proto::expr"><code>proto::expr<></code></classname> or
+ <classname alt="boost::proto::basic_expr"><code>proto::basic_expr<></code></classname>
that is equivalent to Expr. Expression types are equivalent if they have the
same <code>proto_tag</code>, <code>proto_args</code>, and <code>proto_arity</code>.
</simpara>
@@ -164,7 +181,8 @@
</return-type>
<semantics>
Returns an object of type
- <classname alt="boost::proto::expr"><code>proto::expr<></code></classname>
+ <classname alt="boost::proto::expr"><code>proto::expr<></code></classname> or
+ <classname alt="boost::proto::basic_expr"><code>proto::basic_expr<></code></classname>
that is equivalent to <code>e</code>.
</semantics>
</valid-expression>
Modified: branches/release/libs/proto/doc/reference/domain.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/domain.xml (original)
+++ branches/release/libs/proto/doc/reference/domain.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -132,6 +132,69 @@
</typedef>
</struct>
+ <!-- proto::use_basic_expr -->
+ <struct name="use_basic_expr">
+ <template>
+ <template-type-parameter name="Domain"/>
+ </template>
+ <description>
+ <para>
+ Annotate a domain to indicate that its generator would
+ prefer to be passed instances of
+ <computeroutput><classname>proto::basic_expr</classname><></computeroutput> rather than
+ <computeroutput><classname>proto::expr</classname><></computeroutput>.
+ <computeroutput>use_basic_expr< Domain ></computeroutput> is itself a domain.
+ </para>
+ </description>
+ </struct>
+
+ <!-- proto::wants_basic_expr -->
+ <struct name="wants_basic_expr">
+ <template>
+ <template-type-parameter name="Domain"/>
+ </template>
+ <description>
+ <para>
+ A Boolean metafunction that tests a domain to see whether
+ its generator would prefer to be passed instances of
+ <computeroutput><classname>proto::basic_expr</classname><></computeroutput> rather than
+ <computeroutput><classname>proto::expr</classname><></computeroutput>.
+ </para>
+ </description>
+ <inherit>
+ <type>mpl::bool_< <replaceable>true-or-false</replaceable> ></type>
+ </inherit>
+ </struct>
+
+ <!-- proto::wants_basic_expr -->
+ <struct name="base_expr">
+ <template>
+ <template-type-parameter name="Domain"/>
+ <template-type-parameter name="Tag"/>
+ <template-type-parameter name="Args"/>
+ </template>
+ <description>
+ <para>
+ Given a domain, a tag type and an argument list,
+ compute the type of the expression to generate. This is
+ either an instance of
+ <computeroutput><classname>proto::basic_expr</classname><></computeroutput> or
+ <computeroutput><classname>proto::expr</classname><></computeroutput>.
+ </para>
+ </description>
+ <typedef name="A">
+ <purpose>For exposition only</purpose>
+ <type><classname>proto::basic_expr</classname>< Tag, Args ></type>
+ </typedef>
+ <typedef name="B">
+ <purpose>For exposition only</purpose>
+ <type><classname>proto::expr</classname>< Tag, Args ></type>
+ </typedef>
+ <typedef name="type">
+ <type>typename mpl::if_<<classname>proto::wants_basic_expr</classname>< Domain >, A, B>::type</type>
+ </typedef>
+ </struct>
+
</namespace>
</namespace>
</header>
Modified: branches/release/libs/proto/doc/reference/expr.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/expr.xml (original)
+++ branches/release/libs/proto/doc/reference/expr.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -3,6 +3,140 @@
<namespace name="boost">
<namespace name="proto">
+ <!-- boost::proto::basic_expr -->
+
+ <struct name="basic_expr">
+ <template>
+ <template-type-parameter name="Tag"/>
+ <template-type-parameter name="Args"/>
+ <template-nontype-parameter name="Arity">
+ <type>long</type>
+ <default>Args::arity</default>
+ </template-nontype-parameter>
+ </template>
+
+ <purpose>Simplified representation of a node in an expression tree.</purpose>
+
+ <description>
+ <para>
+ <computeroutput>proto::basic_expr<></computeroutput> is a node in an expression
+ template tree. It is a container for its child sub-trees. It also serves as the
+ terminal nodes of the tree.
+ </para>
+ <para>
+ <computeroutput>Tag</computeroutput> is type that represents the operation
+ encoded by this expression. It is typically one of the structs in the
+ <computeroutput>boost::proto::tag</computeroutput> namespace, but it doesn't
+ have to be. If <computeroutput>Arity</computeroutput> is 0 then this
+ <computeroutput>expr<></computeroutput> type represents a leaf in the
+ expression tree.
+ </para>
+ <para>
+ <computeroutput>Args</computeroutput> is a list of types representing
+ the children of this expression. It is an instantiation of one of
+ <computeroutput><classname alt="proto::listN">proto::list1<></classname></computeroutput>,
+ <computeroutput><classname alt="proto::listN">proto::list2<></classname></computeroutput>,
+ etc. The child types
+ must all themselves be either <computeroutput>proto::expr<></computeroutput>
+ or <computeroutput>proto::basic_expr<>&</computeroutput> (or extensions thereof via
+ <computeroutput><classname>proto::extends<></classname></computeroutput> or
+ <computeroutput><macroname>BOOST_PROTO_EXTENDS</macroname>()</computeroutput>), unless
+ <computeroutput>Arity</computeroutput> is 0, in which case
+ <computeroutput>Args</computeroutput> must be
+ <computeroutput>proto::term<T></computeroutput>, where
+ <computeroutput>T</computeroutput> can be any type.
+ </para>
+ <para>
+ <computeroutput>proto::basic_expr<></computeroutput> is a valid Fusion
+ random-access sequence, where the elements of the sequence are the child
+ expressions.
+ </para>
+ </description>
+
+ <!-- typedefs -->
+
+ <typedef name="proto_tag">
+ <type>Tag</type>
+ </typedef>
+
+ <typedef name="proto_args">
+ <type>Args</type>
+ </typedef>
+
+ <typedef name="proto_arity">
+ <type>mpl::long_< Arity ></type>
+ </typedef>
+
+ <typedef name="proto_domain">
+ <type><classname>proto::default_domain</classname></type>
+ </typedef>
+
+ <typedef name="proto_grammar">
+ <type>basic_expr</type>
+ </typedef>
+
+ <typedef name="proto_base_expr">
+ <type>basic_expr</type>
+ </typedef>
+
+ <typedef name="proto_derived_expr">
+ <type>basic_expr</type>
+ </typedef>
+
+ <typedef name="proto_childN">
+ <type>typename Args::child<replaceable>N</replaceable></type>
+ <purpose>For each <replaceable>N</replaceable> in <replaceable>[0,max(Arity,1))</replaceable>.</purpose>
+ </typedef>
+
+ <method-group name="public static functions">
+
+ <!-- make -->
+ <method name="make" specifiers="static">
+ <type>basic_expr const</type>
+ <template>
+ <template-type-parameter name="A" pack="1"/>
+ </template>
+ <parameter name="a" pack="1">
+ <paramtype>A const &</paramtype>
+ </parameter>
+ <requires>
+ <para>
+ The number of supplied arguments must be <computeroutput>max(Arity,1)</computeroutput>.
+ </para>
+ </requires>
+ <returns>
+ <para>
+ A new <computeroutput>basic_expr</computeroutput> object initialized with the specified arguments.
+ </para>
+ </returns>
+ </method>
+
+ </method-group>
+
+ <method-group name="public member functions">
+
+ <method name="proto_base">
+ <type>basic_expr &</type>
+ <returns>
+ <para>
+ <computeroutput>*this</computeroutput>
+ </para>
+ </returns>
+ </method>
+
+ <method name="proto_base" cv="const">
+ <type>basic_expr const &</type>
+ <description>
+ <para>
+ This is an overloaded member function, provided for convenience. It differs from
+ the above function only in what argument(s) it accepts.
+ </para>
+ </description>
+ </method>
+
+ </method-group>
+ </struct>
+
<!-- boost::proto::expr -->
<struct name="expr">
@@ -38,7 +172,7 @@
<computeroutput><classname alt="proto::listN">proto::list2<></classname></computeroutput>,
etc. The child types
must all themselves be either <computeroutput>proto::expr<></computeroutput>
- or <computeroutput>proto::expr<>&</computeroutput> (or extensions thereof via
+ or <computeroutput>proto::basic_expr<>&</computeroutput> (or extensions thereof via
<computeroutput><classname>proto::extends<></classname></computeroutput> or
<computeroutput><macroname>BOOST_PROTO_EXTENDS</macroname>()</computeroutput>), unless
<computeroutput>Arity</computeroutput> is 0, in which case
@@ -71,6 +205,10 @@
<type><classname>proto::default_domain</classname></type>
</typedef>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< Tag, Args, Arity ></type>
+ </typedef>
+
<typedef name="proto_base_expr">
<type>expr</type>
</typedef>
Modified: branches/release/libs/proto/doc/reference/extends.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/extends.xml (original)
+++ branches/release/libs/proto/doc/reference/extends.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -136,6 +136,9 @@
<typedef name="proto_arity">
<type>typename proto_base_expr::proto_arity</type>
</typedef>
+ <typedef name="proto_grammar">
+ <type>typename proto_base_expr::proto_grammar</type>
+ </typedef>
<typedef name="proto_childN">
<purpose>For each <replaceable>N</replaceable> in <replaceable>[0,max(1,proto_arity_c))</replaceable></purpose>
<type>typename proto_base_expr::proto_child<replaceable>N</replaceable></type>
Modified: branches/release/libs/proto/doc/reference/make_expr.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/make_expr.xml (original)
+++ branches/release/libs/proto/doc/reference/make_expr.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -209,15 +209,15 @@
If <computeroutput>Tag</computeroutput> is
<computeroutput><classname>proto::tag::terminal</classname></computeroutput>, then
<computeroutput>type</computeroutput> is a typedef for
- <computeroutput>boost::result_of<Domain(<classname>proto::expr</classname><
- <classname>proto::tag::terminal</classname>, <classname>proto::term</classname><
- A<subscript>0</subscript> > >)>::type</computeroutput>.
+ <computeroutput>boost::result_of<Domain(typename <classname>proto::base_expr</classname><
+ Domain, <classname>proto::tag::terminal</classname>, <classname>proto::term</classname><
+ A<subscript>0</subscript> > >::type)>::type</computeroutput>.
</para>
<para>
Otherwise, <computeroutput>type</computeroutput> is a typedef for
- <computeroutput>boost::result_of<Domain(<classname>proto::expr</classname><
- Tag, <classname alt="proto::listN">proto::list<emphasis>N</emphasis></classname><
- typename <classname>proto::result_of::as_child</classname><A>::type...> >)>::type</computeroutput>
+ <computeroutput>boost::result_of<Domain(typename <classname>proto::base_expr</classname><
+ Domain, Tag, <classname alt="proto::listN">proto::list<emphasis>N</emphasis></classname><
+ typename <classname>proto::result_of::as_child</classname><A>::type...> >::type)>::type</computeroutput>
</para>
</description>
<type><emphasis>see-below</emphasis></type>
@@ -352,7 +352,7 @@
</listitem>
</itemizedlist>
Let <computeroutput><replaceable>MAKE</replaceable><Tag>(a...)</computeroutput> be defined as
- <computeroutput><classname>proto::expr</classname><Tag,
+ <computeroutput><classname>proto::base_expr</classname><Domain, Tag,
<classname alt="proto::listN">proto::list<emphasis>N</emphasis></classname><A...> >::make(a...)</computeroutput>
where
<computeroutput>A<subscript>x</subscript></computeroutput> is the type of
@@ -426,7 +426,7 @@
</listitem>
</itemizedlist>
Let <computeroutput><replaceable>MAKE</replaceable><Tag>(a...)</computeroutput> be defined as
- <computeroutput><classname>proto::expr</classname><Tag,
+ <computeroutput><classname>proto::base_expr</classname><Domain, Tag,
<classname alt="proto::listN">proto::list<emphasis>N</emphasis></classname><A...> >::make(a...)</computeroutput>
where
<computeroutput>A<subscript>x</subscript></computeroutput> is the type of
Modified: branches/release/libs/proto/doc/reference/matches.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/matches.xml (original)
+++ branches/release/libs/proto/doc/reference/matches.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -82,7 +82,7 @@
</method>
</method-group>
</struct>
- <typedef name="proto_base_expr">
+ <typedef name="proto_grammar">
<type>_</type>
</typedef>
</struct>
@@ -144,7 +144,7 @@
</method>
</method-group>
</struct>
- <typedef name="proto_base_expr">
+ <typedef name="proto_grammar">
<type>not_</type>
</typedef>
</struct>
@@ -262,7 +262,7 @@
</method>
</method-group>
</struct>
- <typedef name="proto_base_expr">
+ <typedef name="proto_grammar">
<type>if_</type>
</typedef>
</struct>
@@ -345,7 +345,7 @@
</method>
</method-group>
</struct>
- <typedef name="proto_base_expr">
+ <typedef name="proto_grammar">
<type>or_</type>
</typedef>
</struct>
@@ -418,7 +418,7 @@
</method>
</method-group>
</struct>
- <typedef name="proto_base_expr">
+ <typedef name="proto_grammar">
<type>and_</type>
</typedef>
</struct>
@@ -457,7 +457,7 @@
<inherit><type>
Cases::template case_<typename Expr::tag_type>::template impl<Expr, State, Data></type></inherit>
</struct>
- <typedef name="proto_base_expr">
+ <typedef name="proto_grammar">
<type>switch_</type>
</typedef>
</struct>
@@ -503,9 +503,9 @@
<purpose>For matching a Grammar to a variable number of sub-expressions.</purpose>
<description>
<para>
- An expression type <computeroutput><classname>proto::expr</classname><AT,
+ An expression type <computeroutput><classname>proto::basic_expr</classname><AT,
<classname alt="proto::listN">proto::list<replaceable>N</replaceable></classname><A<subscript>0</subscript>,...A<subscript>n</subscript>,U<subscript>0</subscript>,...U<subscript>m</subscript>> ></computeroutput>
- matches a grammar <computeroutput><classname>proto::expr</classname><BT,
+ matches a grammar <computeroutput><classname>proto::basic_expr</classname><BT,
<classname alt="proto::listN">proto::list<replaceable>M</replaceable></classname><B<subscript>0</subscript>,...B<subscript>n</subscript>,proto::vararg<V> > ></computeroutput>
if <computeroutput>BT</computeroutput> is <computeroutput><classname>proto::_</classname></computeroutput>
or <computeroutput>AT</computeroutput>, and if
@@ -541,8 +541,8 @@
<para>
<computeroutput>proto::matches<Expr, Grammar></computeroutput> inherits from
<computeroutput>mpl::true_</computeroutput> if
- <computeroutput>Expr::proto_base_expr</computeroutput> matches
- <computeroutput>Grammar::proto_base_expr</computeroutput>, and from
+ <computeroutput>Expr::proto_grammar</computeroutput> matches
+ <computeroutput>Grammar::proto_grammar</computeroutput>, and from
<computeroutput>mpl::false_</computeroutput> otherwise.
</para>
<para>
@@ -559,7 +559,7 @@
<para>
An expression
<computeroutput>
- <classname>proto::expr</classname><AT,
+ <classname>proto::basic_expr</classname><AT,
<classname alt="proto::listN">
proto::list<replaceable>N</replaceable>
</classname><A<subscript>0</subscript>,...A<subscript>n</subscript>>
@@ -567,7 +567,7 @@
</computeroutput>
matches a grammar
<computeroutput>
- <classname>proto::expr</classname><BT,
+ <classname>proto::basic_expr</classname><BT,
<classname alt="proto::listN">
proto::list<replaceable>N</replaceable>
</classname><B<subscript>0</subscript>,...B<subscript>n</subscript>>
@@ -588,14 +588,14 @@
<para>
An expression
<computeroutput>
- <classname>proto::expr</classname><AT,
+ <classname>proto::basic_expr</classname><AT,
<classname alt="proto::listN">
proto::list<replaceable>N</replaceable>
</classname><A<subscript>0</subscript>,...A<subscript>n</subscript>,U<subscript>0</subscript>,...U<subscript>m</subscript>>
>
</computeroutput> matches a grammar
<computeroutput>
- <classname>proto::expr</classname><BT,
+ <classname>proto::basic_expr</classname><BT,
<classname alt="proto::listN">
proto::list<replaceable>M</replaceable>
</classname><B<subscript>0</subscript>,...B<subscript>n</subscript>,<classname>proto::vararg</classname><V>
@@ -700,11 +700,11 @@
<para>
A terminal expression
<computeroutput>
- <classname>proto::expr</classname><AT,
+ <classname>proto::basic_expr</classname><AT,
<classname>proto::term</classname><A> >
</computeroutput> matches a grammar
<computeroutput>
- <classname>proto::expr</classname><BT, <classname>proto::term</classname><B> >
+ <classname>proto::basic_expr</classname><BT, <classname>proto::term</classname><B> >
</computeroutput>
if <computeroutput>BT</computeroutput> is <computeroutput><classname>proto::_</classname></computeroutput>
or <computeroutput>AT</computeroutput> and one of the following is true:
Modified: branches/release/libs/proto/doc/reference/traits.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/traits.xml (original)
+++ branches/release/libs/proto/doc/reference/traits.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -71,7 +71,8 @@
<computeroutput>T t(a<subscript>0</subscript>,...a<subscript>n</subscript>)</computeroutput>.
</para>
<para>
- Note: <computeroutput><classname>proto::expr<></classname> is an aggregate.</computeroutput>
+ Note: <computeroutput><classname>proto::expr<></classname></computeroutput> and
+ <computeroutput><classname>proto::basic_expr<></classname></computeroutput>are aggregates.
</para>
</description>
<inherit><type>mpl::bool_<<replaceable>true-or-false</replaceable>></type></inherit>
@@ -595,8 +596,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::terminal</classname>, <classname>proto::term</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::terminal</classname>, <classname>proto::term</classname>< T > ></type>
</typedef>
</struct>
@@ -626,8 +627,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::if_else_</classname>, <classname alt="proto::listN">proto::list3</classname>< T, U, V > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::if_else_</classname>, <classname alt="proto::listN">proto::list3</classname>< T, U, V > ></type>
</typedef>
</struct>
@@ -654,8 +655,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::unary_plus</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::unary_plus</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -682,8 +683,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::negate</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::negate</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -710,8 +711,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::dereference</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::dereference</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -738,8 +739,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::complement</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::complement</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -766,8 +767,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::address_of</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::address_of</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -794,8 +795,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::logical_not</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::logical_not</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -822,8 +823,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::pre_inc</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::pre_inc</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -850,8 +851,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::pre_dec</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::pre_dec</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -878,8 +879,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::post_inc</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::post_inc</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -906,8 +907,10 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::post_dec</classname>, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type>
+ <classname>proto::basic_expr</classname>< <classname>proto::tag::post_dec</classname>, <classname alt="proto::listN">proto::list1</classname>< T > >
+ </type>
</typedef>
</struct>
@@ -935,8 +938,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::shift_left</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::shift_left</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -964,8 +967,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::shift_right</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::shift_right</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -993,8 +996,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::multiplies</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::multiplies</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1022,8 +1025,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::divides</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::divides</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1051,8 +1054,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::modulus</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::modulus</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1080,8 +1083,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::plus</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::plus</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1109,8 +1112,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::minus</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::minus</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1138,8 +1141,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::less</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::less</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1167,8 +1170,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::greater</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::greater</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1196,8 +1199,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::less_equal</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::less_equal</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1225,8 +1228,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::greater_equal</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::greater_equal</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1254,8 +1257,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::equal_to</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::equal_to</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1283,8 +1286,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::not_equal_to</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::not_equal_to</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1312,8 +1315,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::logical_or</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::logical_or</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1341,8 +1344,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::logical_and</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::logical_and</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1370,8 +1373,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::bitwise_and</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::bitwise_and</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1399,8 +1402,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::bitwise_or</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::bitwise_or</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1428,8 +1431,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::bitwise_xor</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::bitwise_xor</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1457,8 +1460,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::comma</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::comma</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1481,8 +1484,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::mem_ptr</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::mem_ptr</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1510,8 +1513,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1539,8 +1542,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::shift_left_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::shift_left_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1568,8 +1571,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::shift_right_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::shift_right_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1597,8 +1600,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::multiplies_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::multiplies_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1626,8 +1629,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::divides_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::divides_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1655,8 +1658,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::modulus_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::modulus_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1684,8 +1687,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::plus_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::plus_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1713,8 +1716,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::minus_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::minus_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1742,8 +1745,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::bitwise_and_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::bitwise_and_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1771,8 +1774,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::bitwise_or_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::bitwise_or_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1800,8 +1803,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::bitwise_xor_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::bitwise_xor_assign</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1829,8 +1832,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::subscript</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::subscript</classname>, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -1858,8 +1861,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< <classname>proto::tag::function</classname>, <classname alt="proto::listN">proto::list<replaceable>N</replaceable></classname>< A... > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< <classname>proto::tag::function</classname>, <classname alt="proto::listN">proto::list<replaceable>N</replaceable></classname>< A... > ></type>
</typedef>
</struct>
@@ -1922,8 +1925,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< Tag, <classname>proto::term</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< Tag, <classname>proto::term</classname>< T > ></type>
</typedef>
</struct>
@@ -1958,8 +1961,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< Tag, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< Tag, <classname alt="proto::listN">proto::list1</classname>< T > ></type>
</typedef>
</struct>
@@ -1994,8 +1997,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< Tag, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< Tag, <classname alt="proto::listN">proto::list2</classname>< T, U > ></type>
</typedef>
</struct>
@@ -2030,8 +2033,8 @@
<typedef name="type">
<type><classname>proto::expr</classname>< Tag, <classname alt="proto::listN">proto::list<replaceable>N</replaceable></classname>< A... > ></type>
</typedef>
- <typedef name="proto_base_expr">
- <type>type</type>
+ <typedef name="proto_grammar">
+ <type><classname>proto::basic_expr</classname>< Tag, <classname alt="proto::listN">proto::list<replaceable>N</replaceable></classname>< A... > ></type>
</typedef>
</struct>
@@ -2044,8 +2047,9 @@
is a Proto expression type.</purpose>
<description>
<para>
- If <computeroutput>T</computeroutput> is an instantiation of <computeroutput>
- <classname alt="proto::expr">proto::expr<></classname></computeroutput> or is an extension
+ If <computeroutput>T</computeroutput> is an instantiation of
+ <computeroutput><classname alt="proto::expr">proto::expr<></classname></computeroutput> or
+ <computeroutput><classname alt="proto::basic_expr">proto::basic_expr<></classname></computeroutput> or is an extension
(via <classname alt="proto::extends">proto::extends<></classname> or
<macroname>BOOST_PROTO_EXTENDS</macroname>()) of such an instantiation,
<computeroutput><classname>proto::is_expr</classname><T>::value</computeroutput>
@@ -2099,7 +2103,7 @@
<computeroutput>A</computeroutput> be <computeroutput>T &</computeroutput>. Otherwise, let
<computeroutput>A</computeroutput> be the type <computeroutput>T</computeroutput> stripped of
cv-qualifiers. Then, the result type <computeroutput>proto::result_of::as_expr<T, Domain>::type</computeroutput>
- is <computeroutput>boost::result_of<Domain(<classname>proto::expr</classname>< <classname>proto::tag::terminal</classname>, <classname>proto::term</classname><A> >)>::type</computeroutput>.
+ is <computeroutput>boost::result_of<Domain(typename <classname>proto::base_expr</classname><Domain, <classname>proto::tag::terminal</classname>, <classname>proto::term</classname><A> >::type)>::type</computeroutput>.
</para>
</description>
<typedef name="type">
@@ -2125,7 +2129,7 @@
<para>
When <computeroutput>T</computeroutput> is not yet a Proto type,
the result type <computeroutput>proto::result_of::as_child<T, Domain>::type</computeroutput> is
- <computeroutput>boost::result_of<Domain(<classname>proto::expr</classname>< <classname>proto::tag::terminal</classname>, <classname>proto::term</classname><T &> >)>::type</computeroutput>.
+ <computeroutput>boost::result_of<Domain(typename <classname>proto::base_expr</classname><Domain, <classname>proto::tag::terminal</classname>, <classname>proto::term</classname><T &> >::type)>::type</computeroutput>.
</para>
<para>
When <computeroutput>T</computeroutput> is already a Proto type
Modified: branches/release/libs/proto/doc/reference/transform/pass_through.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/transform/pass_through.xml (original)
+++ branches/release/libs/proto/doc/reference/transform/pass_through.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -106,7 +106,7 @@
</typedef>
<typedef name="expr_type">
<purpose>For exposition only</purpose>
- <type><classname>proto::expr</classname><T, <classname>proto::listN</classname><R0,...RN> ></type>
+ <type>typename <classname>proto::base_expr</classname><D, T, <classname>proto::listN</classname><R0,...RN> >::type</type>
</typedef>
<typedef name="result_type">
<type>typename boost::result_of<D(expr_type)>::type</type>
Modified: branches/release/libs/proto/doc/reference/transform/when.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/transform/when.xml (original)
+++ branches/release/libs/proto/doc/reference/transform/when.xml 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -55,8 +55,8 @@
</itemizedlist>
</description>
<inherit><type>PrimitiveTransform</type></inherit>
- <typedef name="proto_base_expr">
- <type>typename Grammar::proto_base_expr</type>
+ <typedef name="proto_grammar">
+ <type>typename Grammar::proto_grammar</type>
</typedef>
</struct>
@@ -184,8 +184,8 @@
</method>
</method-group>
</struct>
- <typedef name="proto_base_expr">
- <type>typename Grammar::proto_base_expr</type>
+ <typedef name="proto_grammar">
+ <type>typename Grammar::proto_grammar</type>
</typedef>
</struct-specialization>
Modified: branches/release/libs/proto/test/make_expr.cpp
==============================================================================
--- branches/release/libs/proto/test/make_expr.cpp (original)
+++ branches/release/libs/proto/test/make_expr.cpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -38,13 +38,31 @@
unary_plus<terminal<int>::type>::type p2 = make_expr<tag::unary_plus>(i);
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int>::type> >::type> p3 = make_expr<tag::unary_plus, mydomain>(i);
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::unary_plus
+ , proto::list1<
+ ewrap<proto::basic_expr<tag::terminal, proto::term<int> > >
+ >
+ >
+ >
+ p3_type;
+ p3_type p3 = make_expr<tag::unary_plus, mydomain>(i);
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
- ewrap<plus<
- ewrap<unary_plus<ewrap<terminal<int>::type> >::type>
- , ewrap<terminal<int>::type>
- >::type> p4 = make_expr<tag::plus>(p3, 0);
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::plus
+ , proto::list2<
+ p3_type
+ , ewrap<proto::basic_expr<tag::terminal, proto::term<int> > >
+ >
+ >
+ >
+ p4_type;
+ p4_type p4 = make_expr<tag::plus>(p3, 0);
BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
}
@@ -58,13 +76,31 @@
unary_plus<terminal<int &>::type>::type p2 = make_expr<tag::unary_plus>(boost::ref(i));
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> p3 = make_expr<tag::unary_plus, mydomain>(boost::ref(i));
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::unary_plus
+ , proto::list1<
+ ewrap<proto::basic_expr<tag::terminal, proto::term<int &> > >
+ >
+ >
+ >
+ p3_type;
+ p3_type p3 = make_expr<tag::unary_plus, mydomain>(boost::ref(i));
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
- ewrap<plus<
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> &
- , ewrap<terminal<int>::type>
- >::type> p4 = make_expr<tag::plus>(boost::ref(p3), 0);
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::plus
+ , proto::list2<
+ p3_type &
+ , ewrap<proto::basic_expr<tag::terminal, proto::term<int> > >
+ >
+ >
+ >
+ p4_type;
+ p4_type p4 = make_expr<tag::plus>(boost::ref(p3), 0);
BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
}
@@ -77,14 +113,31 @@
unary_plus<terminal<int>::type>::type p2 = functional::make_expr<tag::unary_plus>()(i);
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int>::type> >::type> p3 = functional::make_expr<tag::unary_plus, mydomain>()(i);
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::unary_plus
+ , proto::list1<
+ ewrap<proto::basic_expr<tag::terminal, proto::term<int> > >
+ >
+ >
+ >
+ p3_type;
+ p3_type p3 = functional::make_expr<tag::unary_plus, mydomain>()(i);
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
- ewrap<plus<
- ewrap<unary_plus<ewrap<terminal<int>::type> >::type>
- , ewrap<terminal<int>::type>
- >::type> p4 = functional::make_expr<tag::plus, mydomain>()(p3, 0);
- BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::plus
+ , proto::list2<
+ p3_type
+ , ewrap<proto::basic_expr<tag::terminal, proto::term<int> > >
+ >
+ >
+ >
+ p4_type;
+ p4_type p4 = functional::make_expr<tag::plus>()(p3, 0);
}
void test_make_expr_functional_ref()
@@ -97,13 +150,31 @@
unary_plus<terminal<int &>::type>::type p2 = functional::make_expr<tag::unary_plus>()(boost::ref(i));
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> p3 = functional::make_expr<tag::unary_plus, mydomain>()(boost::ref(i));
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::unary_plus
+ , proto::list1<
+ ewrap<proto::basic_expr<tag::terminal, proto::term<int &> > >
+ >
+ >
+ >
+ p3_type;
+ p3_type p3 = functional::make_expr<tag::unary_plus, mydomain>()(boost::ref(i));
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
- ewrap<plus<
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> &
- , ewrap<terminal<int>::type>
- >::type> p4 = functional::make_expr<tag::plus, mydomain>()(boost::ref(p3), 0);
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::plus
+ , proto::list2<
+ p3_type &
+ , ewrap<proto::basic_expr<tag::terminal, proto::term<int> > >
+ >
+ >
+ >
+ p4_type;
+ p4_type p4 = functional::make_expr<tag::plus>()(boost::ref(p3), 0);
BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
}
@@ -116,13 +187,31 @@
unary_plus<terminal<int &>::type>::type p2 = unpack_expr<tag::unary_plus>(fusion::make_tuple(boost::ref(i)));
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> p3 = unpack_expr<tag::unary_plus, mydomain>(fusion::make_tuple(boost::ref(i)));
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::unary_plus
+ , proto::list1<
+ ewrap<proto::basic_expr<tag::terminal, proto::term<int &> > >
+ >
+ >
+ >
+ p3_type;
+ p3_type p3 = unpack_expr<tag::unary_plus, mydomain>(fusion::make_tuple(boost::ref(i)));
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
- ewrap<plus<
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> &
- , ewrap<terminal<int>::type>
- >::type> p4 = unpack_expr<tag::plus>(fusion::make_tuple(boost::ref(p3), 0));
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::plus
+ , proto::list2<
+ p3_type &
+ , ewrap<proto::basic_expr<tag::terminal, proto::term<int> > >
+ >
+ >
+ >
+ p4_type;
+ p4_type p4 = unpack_expr<tag::plus>(fusion::make_tuple(boost::ref(p3), 0));
BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
}
@@ -135,13 +224,31 @@
unary_plus<terminal<int &>::type>::type p2 = functional::unpack_expr<tag::unary_plus>()(fusion::make_tuple(boost::ref(i)));
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> p3 = functional::unpack_expr<tag::unary_plus, mydomain>()(fusion::make_tuple(boost::ref(i)));
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::unary_plus
+ , proto::list1<
+ ewrap<proto::basic_expr<tag::terminal, proto::term<int &> > >
+ >
+ >
+ >
+ p3_type;
+ p3_type p3 = functional::unpack_expr<tag::unary_plus, mydomain>()(fusion::make_tuple(boost::ref(i)));
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
- ewrap<plus<
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> &
- , ewrap<terminal<int>::type>
- >::type> p4 = functional::unpack_expr<tag::plus>()(fusion::make_tuple(boost::ref(p3), 0));
+ typedef
+ ewrap<
+ proto::basic_expr<
+ tag::plus
+ , proto::list2<
+ p3_type &
+ , ewrap<proto::basic_expr<tag::terminal, proto::term<int> > >
+ >
+ >
+ >
+ p4_type;
+ p4_type p4 = functional::unpack_expr<tag::plus>()(fusion::make_tuple(boost::ref(p3), 0));
BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
}
Modified: branches/release/libs/proto/test/proto_fusion_s.cpp
==============================================================================
--- branches/release/libs/proto/test/proto_fusion_s.cpp (original)
+++ branches/release/libs/proto/test/proto_fusion_s.cpp 2010-06-10 11:03:27 EDT (Thu, 10 Jun 2010)
@@ -28,6 +28,12 @@
return sout << boost::proto::value(*op);
}
+template<typename Args>
+std::ostream &operator <<(std::ostream &sout, boost::proto::basic_expr<boost::proto::tag::terminal, Args, 0> const *op)
+{
+ return sout << boost::proto::value(*op);
+}
+
template<typename Tag, typename Args>
std::ostream &operator <<(std::ostream &sout, boost::proto::expr<Tag, Args, 1> const *op)
{
@@ -35,11 +41,23 @@
}
template<typename Tag, typename Args>
+std::ostream &operator <<(std::ostream &sout, boost::proto::basic_expr<Tag, Args, 1> const *op)
+{
+ return sout << Tag() << boost::addressof(boost::proto::child(*op).proto_base());
+}
+
+template<typename Tag, typename Args>
std::ostream &operator <<(std::ostream &sout, boost::proto::expr<Tag, Args, 2> const *op)
{
return sout << boost::addressof(boost::proto::left(*op).proto_base()) << Tag() << boost::addressof(boost::proto::right(*op).proto_base());
}
+template<typename Tag, typename Args>
+std::ostream &operator <<(std::ostream &sout, boost::proto::basic_expr<Tag, Args, 2> const *op)
+{
+ return sout << boost::addressof(boost::proto::left(*op).proto_base()) << Tag() << boost::addressof(boost::proto::right(*op).proto_base());
+}
+
///////////////////////////////////////////////////////////////////////////////
// to_string
//
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