|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54364 - in trunk: boost/proto boost/proto/transform libs/proto/example
From: eric_at_[hidden]
Date: 2009-06-26 02:09:07
Author: eric_niebler
Date: 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
New Revision: 54364
URL: http://svn.boost.org/trac/boost/changeset/54364
Log:
fix some bugs with use of Transform::result<void(E,S,V)>, which is no longer valid. Make lambda.hpp example work again
Text files modified:
trunk/boost/proto/deep_copy.hpp | 6
trunk/boost/proto/generate.hpp | 10
trunk/boost/proto/make_expr.hpp | 4
trunk/boost/proto/matches.hpp | 49 ++++---
trunk/boost/proto/operators.hpp | 35 ++--
trunk/boost/proto/traits.hpp | 10
trunk/boost/proto/transform/fold.hpp | 2
trunk/boost/proto/transform/make.hpp | 11
trunk/boost/proto/transform/pass_through.hpp | 4
trunk/boost/proto/transform/when.hpp | 6
trunk/libs/proto/example/lambda.hpp | 254 +++++++++++++++++++++++++++------------
11 files changed, 249 insertions(+), 142 deletions(-)
Modified: trunk/boost/proto/deep_copy.hpp
==============================================================================
--- trunk/boost/proto/deep_copy.hpp (original)
+++ trunk/boost/proto/deep_copy.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -41,7 +41,8 @@
>::type
actual_terminal_type;
typedef typename terminal<actual_terminal_type>::type expr_type;
- typedef typename Expr::proto_domain::template result<void(expr_type)>::type type;
+ typedef typename Expr::proto_domain proto_domain;
+ typedef typename proto_domain::template result<proto_domain(expr_type)>::type type;
template<typename Expr2>
static type call(Expr2 const &expr)
@@ -174,7 +175,8 @@
>
expr_type;
- typedef typename Expr::proto_domain::template result<void(expr_type)>::type type;
+ typedef typename Expr::proto_domain proto_domain;
+ typedef typename proto_domain::template result<proto_domain(expr_type)>::type type;
template<typename Expr2>
static type call(Expr2 const &expr)
Modified: trunk/boost/proto/generate.hpp
==============================================================================
--- trunk/boost/proto/generate.hpp (original)
+++ trunk/boost/proto/generate.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -247,7 +247,7 @@
/// \param expr The expression to modify.
/// \return <tt>deep_copy(expr)</tt>
template<typename Expr>
- typename result<void(Expr)>::type operator ()(Expr const &expr) const
+ typename result<by_value_generator(Expr)>::type operator ()(Expr const &expr) const
{
return detail::by_value_generator_<Expr>::make(expr);
}
@@ -276,7 +276,7 @@
{
typedef
typename Second::template result<
- void(typename First::template result<void(Expr)>::type)
+ Second(typename First::template result<First(Expr)>::type)
>::type
type;
};
@@ -286,7 +286,7 @@
{
typedef
typename Second::template result<
- void(typename First::template result<void(Expr)>::type)
+ Second(typename First::template result<First(Expr)>::type)
>::type
type;
};
@@ -296,7 +296,7 @@
{
typedef
typename Second::template result<
- void(typename First::template result<void(Expr)>::type)
+ Second(typename First::template result<First(Expr)>::type)
>::type
type;
};
@@ -304,7 +304,7 @@
/// \param expr The expression to modify.
/// \return Second()(First()(expr))
template<typename Expr>
- typename result<void(Expr)>::type operator ()(Expr const &expr) const
+ typename result<compose_generators(Expr)>::type operator ()(Expr const &expr) const
{
return Second()(First()(expr));
}
Modified: trunk/boost/proto/make_expr.hpp
==============================================================================
--- trunk/boost/proto/make_expr.hpp (original)
+++ trunk/boost/proto/make_expr.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -979,7 +979,7 @@
, N
> expr_type;
- typedef typename Domain::template result<void(expr_type)>::type result_type;
+ typedef typename Domain::template result<Domain(expr_type)>::type result_type;
result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, typename add_reference<A, >::type a)) const
{
@@ -1013,7 +1013,7 @@
, N
> expr_type;
- typedef typename Domain::template result<void(expr_type)>::type type;
+ typedef typename Domain::template result<Domain(expr_type)>::type type;
static type const call(Sequence const &sequence)
{
Modified: trunk/boost/proto/matches.hpp
==============================================================================
--- trunk/boost/proto/matches.hpp (original)
+++ trunk/boost/proto/matches.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -70,19 +70,6 @@
template<typename Expr, typename Grammar>
struct matches_;
- // and_ and or_ implementation
- template<bool B, typename Expr, typename G0>
- struct or_1
- : mpl::bool_<B>
- {
- typedef G0 which;
- };
-
- template<bool B>
- struct and_1
- : mpl::bool_<B>
- {};
-
template<bool B, typename Pred>
struct and_2;
@@ -475,9 +462,9 @@
/// \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>when\<_,T\>::::result\<void(E,int,int)\>::::type::value</tt>
+ /// <tt>boost::result_of\<when\<_,T\>(E,int,int)\>::::type::value</tt>
/// is \c true and \c E matches \c U; or, if
- /// <tt>when\<_,T\>::::result\<void(E,int,int)\>::::type::value</tt>
+ /// <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
@@ -647,15 +634,15 @@
/// 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>when\<_,If\>::::result\<void(E,int,int)\>::::type::value</tt>
+ /// <tt>boost::result_of\<when\<_,If\>(E,int,int)\>::::type::value</tt>
/// is \c true and \c E matches \c U; or, if
- /// <tt>when\<_,If\>::::result\<void(E,int,int)\>::::type::value</tt>
+ /// <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>when\<_,If\>::::result\<void(E,int,int)\>::::type::value</tt>
+ /// <tt>boost::result_of\<when\<_,If\>(E,int,int)\>::::type::value</tt>
/// is \c true.
///
/// \code
@@ -672,7 +659,7 @@
/// 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>when\<_,If\>::::result\<void(E,S,V)\>::::type::value</tt>
+ /// 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.
///
@@ -752,7 +739,8 @@
/// \param s The current state
/// \param d A data of arbitrary type
/// \pre <tt>matches\<Expr,or_\>::::value</tt> is \c true.
- /// \return <tt>result\<void(Expr, State, Data)\>::::which()(e, s, d)</tt>
+ /// \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
@@ -790,7 +778,8 @@
/// \param s The current state
/// \param d A data of arbitrary type
/// \pre <tt>matches\<Expr,and_\>::::value</tt> is \c true.
- /// \return <tt>result\<void(Expr, State, Data)\>::::which()(e, s, d)</tt>
+ /// \return <tt>which()(e, s, d)</tt>, where <tt>which</tt> is
+ /// the last non-void sub-grammar in the <tt>and_\<\></tt>.
};
};
@@ -819,7 +808,8 @@
/// \param s The current state
/// \param d A data of arbitrary type
/// \pre <tt>matches\<Expr,switch_\>::::value</tt> is \c true.
- /// \return <tt>result\<void(Expr, State, Data)\>::::which()(e, s, d)</tt>
+ /// \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
@@ -937,13 +927,21 @@
#define N BOOST_PP_ITERATION()
+ // Assymetry here between the handling of and_N and or_N because
+ // and_N is used by lambda_matches up to BOOST_PROTO_MAX_ARITY,
+ // regardless of how low BOOST_PROTO_MAX_LOGICAL_ARITY is.
template<bool B, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), typename P)>
struct BOOST_PP_CAT(and_, N)
+ #if 2 == N
+ : mpl::bool_<P0::value>
+ {};
+ #else
: BOOST_PP_CAT(and_, BOOST_PP_DEC(N))<
P0::value BOOST_PP_COMMA_IF(BOOST_PP_SUB(N,2))
BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_DEC(N), P)
>
{};
+ #endif
template<BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), typename P)>
struct BOOST_PP_CAT(and_, N)<false, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), P)>
@@ -959,11 +957,18 @@
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>
+ {
+ typedef G1 which;
+ };
+ #else
: BOOST_PP_CAT(or_, BOOST_PP_DEC(N))<
matches_<Expr, typename G1::proto_base_expr>::value
, Expr, BOOST_PP_ENUM_SHIFTED_PARAMS(N, G)
>
{};
+ #endif
template<typename Expr BOOST_PP_ENUM_TRAILING_PARAMS(N, typename G)>
struct BOOST_PP_CAT(or_, N)<true, Expr, BOOST_PP_ENUM_PARAMS(N, G)>
Modified: trunk/boost/proto/operators.hpp
==============================================================================
--- trunk/boost/proto/operators.hpp (original)
+++ trunk/boost/proto/operators.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -32,7 +32,7 @@
struct generate_if
: lazy_enable_if_c<
matches<Expr, typename Domain::proto_grammar>::value
- , typename Domain::template result<void(Expr)>
+ , typename Domain::template result<Domain(Expr)>
>
{};
@@ -47,8 +47,8 @@
struct generate_if_left
: lazy_enable_if_c<
matches<proto::expr<Tag, proto::list2<Left &, Right>, 2>, typename Domain::proto_grammar>::value
- , typename Domain::template result<void(
- proto::expr<Tag, proto::list2<Left &, typename Domain::template result<void(Right)>::type>, 2>
+ , typename Domain::template result<Domain(
+ proto::expr<Tag, proto::list2<Left &, typename Domain::template result<Domain(Right)>::type>, 2>
)>
>
{};
@@ -64,8 +64,8 @@
struct generate_if_right
: lazy_enable_if_c<
matches<proto::expr<Tag, proto::list2<Left, Right &>, 2>, typename Domain::proto_grammar>::value
- , typename Domain::template result<void(
- proto::expr<Tag, proto::list2<typename Domain::template result<void(Left)>::type, Right &>, 2>
+ , typename Domain::template result<Domain(
+ proto::expr<Tag, proto::list2<typename Domain::template result<Domain(Left)>::type, Right &>, 2>
)>
>
{};
@@ -91,14 +91,15 @@
>
{
typedef proto::expr<tag::terminal, term<Right &>, 0> term_type;
- typedef proto::expr<Tag, list2<Left &, typename Left::proto_domain::template result<void(term_type)>::type>, 2> expr_type;
+ typedef typename Left::proto_domain proto_domain;
+ typedef proto::expr<Tag, list2<Left &, typename proto_domain::template result<proto_domain(term_type)>::type>, 2> expr_type;
- static typename Left::proto_domain::template result<void(expr_type)>::type
+ static typename proto_domain::template result<proto_domain(expr_type)>::type
make(Left &left, Right &right)
{
term_type term = {right};
- expr_type that = {left, typename Left::proto_domain()(term)};
- return typename Left::proto_domain()(that);
+ expr_type that = {left, proto_domain()(term)};
+ return proto_domain()(that);
}
};
@@ -112,14 +113,15 @@
>
{
typedef proto::expr<tag::terminal, term<Left &>, 0> term_type;
- typedef proto::expr<Tag, list2<typename Right::proto_domain::template result<void(term_type)>::type, Right &>, 2> expr_type;
+ typedef typename Right::proto_domain proto_domain;
+ typedef proto::expr<Tag, list2<typename proto_domain::template result<proto_domain(term_type)>::type, Right &>, 2> expr_type;
- static typename Right::proto_domain::template result<void(expr_type)>::type
+ static typename proto_domain::template result<proto_domain(expr_type)>::type
make(Left &left, Right &right)
{
term_type term = {left};
- expr_type that = {typename Right::proto_domain()(term), right};
- return typename Right::proto_domain()(that);
+ expr_type that = {proto_domain()(term), right};
+ return proto_domain()(that);
}
};
@@ -136,13 +138,14 @@
>
{
typedef proto::expr<Tag, list2<Left &, Right &>, 2> expr_type;
- BOOST_MPL_ASSERT((is_same<typename Left::proto_domain, typename Right::proto_domain>));
+ typedef typename Left::proto_domain proto_domain;
+ BOOST_MPL_ASSERT((is_same<proto_domain, typename Right::proto_domain>));
- static typename Left::proto_domain::template result<void(expr_type)>::type
+ static typename proto_domain::template result<proto_domain(expr_type)>::type
make(Left &left, Right &right)
{
expr_type that = {left, right};
- return typename Left::proto_domain()(that);
+ return proto_domain()(that);
}
};
Modified: trunk/boost/proto/traits.hpp
==============================================================================
--- trunk/boost/proto/traits.hpp (original)
+++ trunk/boost/proto/traits.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -258,7 +258,7 @@
>::type
arg0_;
typedef proto::expr<proto::tag::terminal, term<arg0_>, 0> expr_;
- typedef typename Domain::template result<void(expr_)>::type type;
+ typedef typename Domain::template result<Domain(expr_)>::type type;
typedef type const reference;
/// INTERNAL ONLY
@@ -291,7 +291,7 @@
>
{
typedef typename T::proto_derived_expr expr_; // removes the const
- typedef typename Domain::template result<void(expr_)>::type type;
+ typedef typename Domain::template result<Domain(expr_)>::type type;
typedef type const reference;
/// INTERNAL ONLY
@@ -346,7 +346,7 @@
struct as_child
{
typedef proto::expr<proto::tag::terminal, term<T &>, 0> expr_;
- typedef typename Domain::template result<void(expr_)>::type type;
+ typedef typename Domain::template result<Domain(expr_)>::type type;
/// INTERNAL ONLY
///
@@ -382,9 +382,9 @@
BOOST_WORKAROUND(BOOST_INTEL, BOOST_TESTED_AT(1010))
// These compilers don't strip top-level cv qualifiers
// on arguments in function types
- typedef typename Domain::template result<void(typename T::proto_derived_expr)>::type type;
+ typedef typename Domain::template result<Domain(typename T::proto_derived_expr)>::type type;
#else
- typedef typename Domain::template result<void(T)>::type type;
+ typedef typename Domain::template result<Domain(T)>::type type;
#endif
/// INTERNAL ONLY
Modified: trunk/boost/proto/transform/fold.hpp
==============================================================================
--- trunk/boost/proto/transform/fold.hpp (original)
+++ trunk/boost/proto/transform/fold.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -54,7 +54,7 @@
#if BOOST_VERSION < 103500
template<typename Expr, typename State>
struct apply
- : result<void(Expr, State)>
+ : result<as_callable(Expr, State)>
{};
#endif
Modified: trunk/boost/proto/transform/make.hpp
==============================================================================
--- trunk/boost/proto/transform/make.hpp (original)
+++ trunk/boost/proto/transform/make.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -217,15 +217,15 @@
/// \li Function pointer types
/// \li Types for which <tt>proto::is_callable\< type \>::::value</tt> is \c true
///
- /// <tt>make\<T\<X0,X1,...\> \>::::result\<void(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>make\<U\<Y0,Y1,...\> \>::::result\<void(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>when\<_, X\>::::result\<void(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.
@@ -387,14 +387,13 @@
template<typename Expr, typename State, typename Data>
struct impl : transform_impl<Expr, State, Data>
{
- /// \brief <tt>make\<Object\>::::result\<void(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;
/// Let \c ax be <tt>when\<_, Ax\>()(e, s, d)</tt>
/// for each \c x in <tt>[0,N]</tt>.
- /// Let \c T be <tt>result\<void(Expr, State, Data)\>::::type</tt>.
- /// Return <tt>T(a0, a1,... aN)</tt>.
+ /// Return <tt>result_type(a0, a1,... aN)</tt>.
///
/// \param e The current expression
/// \param s The current state
Modified: trunk/boost/proto/transform/pass_through.hpp
==============================================================================
--- trunk/boost/proto/transform/pass_through.hpp (original)
+++ trunk/boost/proto/transform/pass_through.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -97,8 +97,8 @@
///
/// \code
/// plus<
- /// T0::result<void(E0, S, V)>::type
- /// , T1::result<void(E1, S, V)>::type
+ /// T0::result<T0(E0, S, V)>::type
+ /// , T1::result<T1(E1, S, V)>::type
/// >::type
/// \endcode
///
Modified: trunk/boost/proto/transform/when.hpp
==============================================================================
--- trunk/boost/proto/transform/when.hpp (original)
+++ trunk/boost/proto/transform/when.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -48,8 +48,8 @@
/// In <tt>when\<G, T\></tt>, when \c T is a class type it is a
/// PrimitiveTransform and the following equivalencies hold:
///
- /// <tt>when\<G,T\>::::result\<void(E,S,V)\>::::type</tt> is the same as
- /// <tt>T::result\<void(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,v)</tt> is the same as
/// <tt>T()(e,s,v)</tt>.
@@ -172,7 +172,7 @@
/// \param s The current state
/// \param d An arbitrary data
/// \pre <tt>matches\<Expr, Grammar\>::::value</tt> is \c true
- /// \return <tt>result\<void(Expr, State, Data)\>::::impl()(e, s, d)</tt>
+ /// \return <tt>which()(e, s, d)</tt>
result_type operator ()(
typename impl::expr_param e
, typename impl::state_param s
Modified: trunk/libs/proto/example/lambda.hpp
==============================================================================
--- trunk/libs/proto/example/lambda.hpp (original)
+++ trunk/libs/proto/example/lambda.hpp 2009-06-26 02:09:05 EDT (Fri, 26 Jun 2009)
@@ -583,7 +583,7 @@
: llresult<Sig>
{};
- typename result<Expr const()>::type
+ typename result<llexpr const()>::type
operator()() const
{
fusion::vector0<> args;
@@ -596,7 +596,7 @@
#define M3(R, SIZE, PRODUCT) \
template<BOOST_PP_ENUM_PARAMS(SIZE, typename A)> \
- typename result<Expr const(BOOST_PP_SEQ_FOR_EACH_I_R(R, M5, ~, PRODUCT))>::type \
+ typename result<llexpr const(BOOST_PP_SEQ_FOR_EACH_I_R(R, M5, ~, PRODUCT))>::type \
operator ()(BOOST_PP_SEQ_FOR_EACH_I_R(R, M4, ~, PRODUCT)) const \
{ \
BOOST_MPL_ASSERT_RELATION(result_of<Arity(Expr const &)>::type::value, <=, SIZE); \
@@ -622,7 +622,7 @@
#define C1 const
- #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_LAMBDA_MAX_ARITY, <boost/lambda2/lambda.hpp>))
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_LAMBDA_MAX_ARITY, "./lambda.hpp"))
#include BOOST_PP_ITERATE()
#undef C0
@@ -650,22 +650,54 @@
typedef llexpr<proto::terminal<exception_placeholder>::type> placeholderE_type;
placeholderE_type const _e = {{{}}};
- template<typename T>
struct byref
{
- typedef llexpr<typename proto::terminal<T &>::type> type;
- };
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename T>
+ struct result<This(T &)>
+ {
+ typedef llexpr<typename proto::terminal<T &>::type> type;
+ };
- template<typename T>
- struct byref<llexpr<T> >
- {
- typedef llexpr<T> &type;
- };
+ template<typename This, typename T>
+ struct result<This(llexpr<T> &)>
+ {
+ typedef boost::reference_wrapper<llexpr<T> > type;
+ };
- template<typename T>
- struct byref<llexpr<T> const>
- {
- typedef llexpr<T> const &type;
+ template<typename This, typename T>
+ struct result<This(llexpr<T> const &)>
+ {
+ typedef boost::reference_wrapper<llexpr<T> const> type;
+ };
+
+ template<typename T>
+ typename result<byref(T &)>::type operator()(T &t) const
+ {
+ typename result<byref(T &)>::type that = {{t}};
+ return that;
+ }
+
+ template<typename T>
+ typename result<byref(T const &)>::type operator()(T const &t) const
+ {
+ typename result<byref(T const &)>::type that = {{t}};
+ return that;
+ }
+
+ template<typename T>
+ boost::reference_wrapper<llexpr<T> > operator()(llexpr<T> &t) const
+ {
+ return boost::ref(t);
+ }
+
+ template<typename T>
+ boost::reference_wrapper<llexpr<T> const> operator()(llexpr<T> const &t) const
+ {
+ return boost::ref(t);
+ }
};
namespace exprns_
@@ -677,23 +709,23 @@
typename proto::result_of::make_expr< \
TAG \
, lldomain \
- , typename byref<T>::type \
+ , typename boost::result_of<byref(T &)>::type \
, U & \
>::type const \
operator OP(T &t, U &u) \
{ \
- return proto::implicit_expr(t, u); \
+ return proto::make_expr<TAG, lldomain>(byref()(t), boost::ref(u)); \
} \
template<typename T, typename U> \
typename proto::result_of::make_expr< \
TAG \
, lldomain \
- , typename byref<T>::type \
+ , typename boost::result_of<byref(T &)>::type \
, U const & \
>::type const \
operator OP(T &t, U const &u) \
{ \
- return proto::implicit_expr(t, u); \
+ return proto::make_expr<TAG, lldomain>(byref()(t), boost::ref(u)); \
} \
/**/
@@ -719,7 +751,8 @@
llexpr<typename proto::terminal<T &>::type> const
var(T &t)
{
- return proto::implicit_expr(t);
+ llexpr<typename proto::terminal<T &>::type> that = {{t}};
+ return that;
}
template<typename T>
@@ -735,7 +768,8 @@
typename constant_type<T>::type const
constant(T const &t)
{
- return proto::implicit_expr(t);
+ typename constant_type<T>::type that = {{t}};
+ return that;
}
template<typename T>
@@ -748,7 +782,8 @@
llexpr<typename proto::terminal<T const &>::type> const
constant_ref(T const &t)
{
- return proto::implicit_expr(t);
+ llexpr<typename proto::terminal<T const &>::type> that = {{t}};
+ return that;
}
template<typename Cond>
@@ -767,7 +802,10 @@
>::type const
operator[](Body const &body) const
{
- return proto::implicit_expr(this->cond, body);
+ return proto::make_expr<tag::while_, lldomain>(
+ boost::ref(this->cond)
+ , boost::ref(body)
+ );
}
private:
@@ -800,7 +838,11 @@
>::type const
operator[](Body2 const &body2) const
{
- return proto::implicit_expr(proto::left(this->if_), proto::right(this->if_), body2);
+ return proto::make_expr<tag::if_else_, lldomain>(
+ boost::ref(proto::left(this->if_))
+ , boost::ref(proto::right(this->if_))
+ , boost::ref(body2)
+ );
}
private:
@@ -837,7 +879,10 @@
> const
operator[](Body const &body) const
{
- return proto::implicit_expr(this->cond, body);
+ return proto::make_expr<tag::if_, lldomain>(
+ boost::ref(this->cond)
+ , boost::ref(body)
+ );
}
private:
@@ -870,7 +915,12 @@
>::type const
operator[](Body const &body) const
{
- return proto::implicit_expr(this->init, this->cond, this->oper, body);
+ return proto::make_expr<tag::for_, lldomain>(
+ boost::ref(this->init)
+ , boost::ref(this->cond)
+ , boost::ref(this->oper)
+ , boost::ref(body)
+ );
}
private:
@@ -901,7 +951,10 @@
>::type const
operator()(Cond const &cond) const
{
- return proto::implicit_expr(this->body, cond);
+ return proto::make_expr<tag::do_while_, lldomain>(
+ boost::ref(this->body)
+ , boost::ref(cond)
+ );
}
private:
@@ -949,7 +1002,12 @@
>::type const
for_loop(Init const &init, Cond const &cond, Oper const &oper)
{
- return proto::implicit_expr(init, cond, oper, noop);
+ return proto::make_expr<tag::for_, lldomain>(
+ boost::ref(init)
+ , boost::ref(cond)
+ , boost::ref(oper)
+ , boost::ref(noop)
+ );
}
template<typename Init, typename Cond, typename Oper, typename Body>
@@ -963,7 +1021,12 @@
>::type const
for_loop(Init const &init, Cond const &cond, Oper const &oper, Body const &body)
{
- return proto::implicit_expr(init, cond, oper, body);
+ return proto::make_expr<tag::for_>(
+ boost::ref(init)
+ , boost::ref(cond)
+ , boost::ref(oper)
+ , boost::ref(body)
+ );
}
template<typename Cond, typename Body>
@@ -975,7 +1038,10 @@
>::type const
while_loop(Cond const &cond, Body const &body)
{
- return proto::implicit_expr(cond, body);
+ return proto::make_expr<tag::while_, lldomain>(
+ boost::ref(cond)
+ , boost::ref(body)
+ );
}
template<typename Cond>
@@ -987,7 +1053,10 @@
>::type const
while_loop(Cond const &cond)
{
- return proto::implicit_expr(cond, noop);
+ return proto::make_expr<tag::while_, lldomain>(
+ boost::ref(cond)
+ , boost::ref(noop)
+ );
}
template<typename Cond, typename Body>
@@ -999,7 +1068,10 @@
>::type const
do_while_loop(Cond const &cond, Body const &body)
{
- return proto::implicit_expr(body, cond);
+ return proto::make_expr<tag::do_while_, lldomain>(
+ boost::ref(body)
+ , boost::ref(cond)
+ );
}
template<typename Cond>
@@ -1011,7 +1083,10 @@
>::type const
do_while_loop(Cond const &cond)
{
- return proto::implicit_expr(noop, cond);
+ return proto::make_expr<tag::do_while_, lldomain>(
+ boost::ref(noop)
+ , boost::ref(cond)
+ );
}
template<typename Cond, typename Body1>
@@ -1023,7 +1098,10 @@
>::type const
if_then(Cond const &cond, Body1 const &body1)
{
- return proto::implicit_expr(cond, body1);
+ return proto::make_expr<tag::if_, lldomain>(
+ boost::ref(cond)
+ , boost::ref(body1)
+ );
}
template<typename Cond, typename Body1, typename Body2>
@@ -1036,7 +1114,11 @@
>::type const
if_then_else(Cond const &cond, Body1 const &body1, Body2 const &body2)
{
- return proto::implicit_expr(cond, body1, body2);
+ return proto::make_expr<tag::if_else_, lldomain>(
+ boost::ref(cond)
+ , boost::ref(body1)
+ , boost::ref(body2)
+ );
}
template<typename Cond, typename Body1, typename Body2>
@@ -1049,7 +1131,11 @@
>::type const
if_then_else_return(Cond const &cond, Body1 const &body1, Body2 const &body2)
{
- return proto::implicit_expr(cond, body1, body2);
+ return proto::make_expr<proto::tag::if_else_, lldomain>(
+ boost::ref(cond)
+ , boost::ref(body1)
+ , boost::ref(body2)
+ );
}
template<typename T>
@@ -1057,31 +1143,31 @@
{
return t;
}
-
- #define M1(Z, N, DATA) \
- template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
+
+ #define M1(N, typename_A, A_const_ref, A_const_ref_a, ref_a) \
+ template<typename_A(N)> \
typename proto::result_of::make_expr< \
proto::tag::function \
, lldomain \
- BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT) \
+ , A_const_ref(N) \
>::type const \
- bind(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) \
+ bind(A_const_ref_a(N)) \
{ \
- return proto::implicit_expr(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
+ return proto::make_expr<proto::tag::function, lldomain>(ref_a(N)); \
} \
\
- template<typename Ret BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, typename A)> \
+ template<typename Ret, typename_A(N)> \
typename proto::result_of::make_expr< \
proto::tag::function \
, lldomain \
- BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT) \
+ , A_const_ref(N) \
>::type const \
- bind(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) \
+ bind(A_const_ref_a(N)) \
{ \
- return proto::implicit_expr(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
+ return proto::make_expr<proto::tag::function, lldomain>(ref_a(N)); \
} \
/**/
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M1, ~)
+ BOOST_PROTO_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M1)
#undef M1
template<typename Ret, typename Expr>
@@ -1117,7 +1203,7 @@
>::type const
protect(Lambda const &lambda)
{
- return proto::implicit_expr(lambda);
+ return proto::make_expr<tag::protect, lldomain>(boost::ref(lambda));
}
template<typename T>
@@ -1154,7 +1240,7 @@
ll_static_cast(U const &u)
{
ll_static_cast_fun<T> fun;
- return proto::implicit_expr(fun, u);
+ return proto::make_expr<proto::tag::function, lldomain>(fun, boost::ref(u));
}
template<typename T>
@@ -1185,7 +1271,7 @@
ll_const_cast(U const &u)
{
ll_const_cast_fun<T> fun;
- return proto::implicit_expr(fun, u);
+ return proto::make_expr<proto::tag::function, lldomain>(fun, boost::ref(u));
}
template<typename T>
@@ -1216,7 +1302,7 @@
ll_dynamic_cast(U const &u)
{
ll_dynamic_cast_fun<T> fun;
- return proto::implicit_expr(fun, u);
+ return proto::make_expr<proto::tag::function, lldomain>(fun, boost::ref(u));
}
template<typename T>
@@ -1247,7 +1333,7 @@
ll_reinterpret_cast(U const &u)
{
ll_reinterpret_cast_fun<T> fun;
- return proto::implicit_expr(fun, u);
+ return proto::make_expr<proto::tag::function, lldomain>(fun, boost::ref(u));
}
struct ll_sizeof_fun
@@ -1271,7 +1357,7 @@
ll_sizeof(U const &u)
{
ll_sizeof_fun fun;
- return proto::implicit_expr(fun, u);
+ return proto::make_expr<proto::tag::function, lldomain>(fun, boost::ref(u));
}
struct ll_typeid_fun
@@ -1295,7 +1381,7 @@
ll_typeid(U const &u)
{
ll_typeid_fun fun;
- return proto::implicit_expr(fun, u);
+ return proto::make_expr<proto::tag::function, lldomain>(fun, boost::ref(u));
}
template<typename T>
@@ -1508,14 +1594,14 @@
typename proto::result_of::make_expr<tag::catch_<E>, lldomain, Expr const &>::type const
catch_exception(Expr const &expr)
{
- return proto::implicit_expr(expr);
+ return proto::make_expr<tag::catch_<E>, lldomain>(boost::ref(expr));
}
template<typename E>
typename proto::result_of::make_expr<tag::catch_<E>, lldomain, noop_type const &>::type const
catch_exception()
{
- return proto::implicit_expr(noop);
+ return proto::make_expr<tag::catch_<E>, lldomain>(boost::ref(noop));
}
template<typename Expr>
@@ -1526,29 +1612,29 @@
>::type const
catch_all(Expr const &expr)
{
- return proto::implicit_expr(expr);
+ return proto::make_expr<tag::catch_all_, lldomain>(boost::ref(expr));
}
inline
proto::result_of::make_expr<tag::catch_all_, lldomain, noop_type const &>::type const
catch_all()
{
- return proto::implicit_expr(noop);
+ return proto::make_expr<tag::catch_all_, lldomain>(boost::ref(noop));
}
- #define M1(Z, N, DATA) \
- template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
+ #define M1(N, typename_A, A_const_ref, A_const_ref_a, ref_a) \
+ template<typename_A(N)> \
typename proto::result_of::make_expr< \
tag::try_ \
, lldomain \
- BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT) \
+ , A_const_ref(N) \
>::type const \
- try_catch(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const & a)) \
+ try_catch(A_const_ref_a(N)) \
{ \
- return proto::implicit_expr(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
+ return proto::make_expr<tag::try_, lldomain>(ref_a(N)); \
} \
/**/
- BOOST_PP_REPEAT_FROM_TO(2, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M1, ~)
+ BOOST_PROTO_REPEAT_FROM_TO(2, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M1)
#undef M1
template<typename Expr>
@@ -1561,15 +1647,14 @@
throw_exception(Expr const &expr)
{
throw_fun fun;
- return proto::implicit_expr(fun, expr);
+ return proto::make_expr<proto::tag::function, lldomain>(fun, boost::ref(expr));
}
inline
proto::result_of::make_expr<proto::tag::function, lldomain, rethrow_fun>::type const
rethrow()
{
- rethrow_fun fun;
- return proto::implicit_expr(fun);
+ return proto::make_expr<proto::tag::function, lldomain>(rethrow_fun());
}
struct make_void_fun
@@ -1590,50 +1675,50 @@
make_void(Expr const &expr)
{
make_void_fun fun;
- return proto::implicit_expr(fun, expr);
+ return proto::make_expr<proto::tag::function, lldomain>(fun, boost::ref(expr));
}
- #define M1(Z, N, DATA) \
- template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
+ #define M1(N, typename_A, A_const_ref, A_const_ref_a, ref_a) \
+ template<typename_A(N)> \
typename proto::result_of::make_expr< \
tag::switch_ \
, lldomain \
- BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT) \
+ , A_const_ref(N) \
>::type const \
- switch_statement(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const & a)) \
+ switch_statement(A_const_ref_a(N)) \
{ \
- return proto::implicit_expr(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
+ return proto::make_expr<tag::switch_, lldomain>(ref_a(N)); \
} \
/**/
- BOOST_PP_REPEAT_FROM_TO(2, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M1, ~)
+ BOOST_PROTO_REPEAT_FROM_TO(2, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M1)
#undef M1
template<int I, typename Expr>
typename proto::result_of::make_expr<tag::case_<I>, lldomain, Expr const &>::type const
case_statement(Expr const &expr)
{
- return proto::implicit_expr(expr);
+ return proto::make_expr<tag::case_<I>, lldomain>(boost::ref(expr));
}
template<int I>
typename proto::result_of::make_expr<tag::case_<I>, lldomain, noop_type const &>::type const
case_statement()
{
- return proto::implicit_expr(noop);
+ return proto::make_expr<tag::case_<I>, lldomain>(boost::ref(noop));
}
template<typename Expr>
typename proto::result_of::make_expr<tag::default_, lldomain, Expr const &>::type const
default_statement(Expr const &expr)
{
- return proto::implicit_expr(expr);
+ return proto::make_expr<tag::default_, lldomain>(boost::ref(expr));
}
inline
proto::result_of::make_expr<tag::default_, lldomain, noop_type const &>::type const
default_statement()
{
- return proto::implicit_expr(noop);
+ return proto::make_expr<tag::default_, lldomain>(boost::ref(noop));
}
namespace ll
@@ -1657,6 +1742,19 @@
}
}}
+
+ namespace boost
+ {
+ template<typename Expr>
+ struct result_of<lambda::llexpr<Expr>()>
+ : lambda::llexpr<Expr>::template result<lambda::llexpr<Expr>()>
+ {};
+
+ template<typename Expr>
+ struct result_of<lambda::llexpr<Expr> const()>
+ : lambda::llexpr<Expr>::template result<lambda::llexpr<Expr> const()>
+ {};
+ }
#ifdef _MSC_VER
# pragma warning(pop)
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