|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2007-12-08 18:17:32
Author: eric_niebler
Date: 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
New Revision: 41911
URL: http://svn.boost.org/trac/boost/changeset/41911
Log:
strict adherence to result_of protocol (work in progress)
Text files modified:
branches/proto/v3/boost/xpressive/detail/core/matcher/action_matcher.hpp | 14 +--
branches/proto/v3/boost/xpressive/detail/static/grammar.hpp | 45 ++++++++--
branches/proto/v3/boost/xpressive/proto/context/callable.hpp | 2
branches/proto/v3/boost/xpressive/proto/context/default.hpp | 11 --
branches/proto/v3/boost/xpressive/proto/deep_copy.hpp | 8 +
branches/proto/v3/boost/xpressive/proto/fusion.hpp | 42 +++++++++-
branches/proto/v3/boost/xpressive/proto/make_expr.hpp | 2
branches/proto/v3/boost/xpressive/proto/matches.hpp | 22 +++--
branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp | 18 +---
branches/proto/v3/boost/xpressive/proto/traits.hpp | 158 ++++++++++++++++++++++++++-------------
branches/proto/v3/boost/xpressive/proto/transform/arg.hpp | 2
branches/proto/v3/boost/xpressive/proto/transform/bind.hpp | 4
branches/proto/v3/boost/xpressive/proto/transform/call.hpp | 47 +++++++++--
branches/proto/v3/boost/xpressive/proto/transform/fold.hpp | 17 ++--
branches/proto/v3/boost/xpressive/proto/transform/fold_tree.hpp | 37 +++++++-
branches/proto/v3/boost/xpressive/proto/transform/make.hpp | 16 ++-
branches/proto/v3/boost/xpressive/proto/transform/when.hpp | 2
branches/proto/v3/boost/xpressive/regex_actions.hpp | 2
branches/proto/v3/libs/xpressive/proto/example/lazy_vector.cpp | 2
branches/proto/v3/libs/xpressive/proto/example/mixed.cpp | 24 ++++-
branches/proto/v3/libs/xpressive/proto/example/vector.cpp | 13 ++
branches/proto/v3/libs/xpressive/proto/test/examples.cpp | 8 +-
22 files changed, 336 insertions(+), 160 deletions(-)
Modified: branches/proto/v3/boost/xpressive/detail/core/matcher/action_matcher.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/core/matcher/action_matcher.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/core/matcher/action_matcher.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -49,11 +49,9 @@
template<typename Expr, long N>
struct child_
- : remove_reference<typename mpl::if_<
- is_const<Expr>
- , typename proto::result_of::arg_c<Expr, N>::const_reference
- , typename proto::result_of::arg_c<Expr, N>::reference
- >::type>
+ : remove_reference<
+ typename proto::result_of::arg_c<Expr, N>::type
+ >
{};
///////////////////////////////////////////////////////////////////////////////
@@ -271,7 +269,7 @@
template<typename This, typename State, typename Index>
struct result<This(State, Index)>
{
- typedef sub_match<typename State::iterator> type;
+ typedef sub_match<typename remove_reference<State>::type::iterator> type;
};
template<typename State, typename Index>
@@ -289,7 +287,7 @@
template<typename This, typename State, typename Attr>
struct result<This(State, Attr)>
{
- typedef typename Attr::matcher_type::value_type::second_type const *type;
+ typedef typename remove_reference<Attr>::type::matcher_type::value_type::second_type const *type;
};
template<typename State, typename Attr>
@@ -333,7 +331,7 @@
template<typename Expr>
struct const_reference
{
- typedef typename proto::result_of::arg<Expr>::const_reference type;
+ typedef typename proto::result_of::arg<Expr>::type type;
};
using grammar_detail::mark_number;
Modified: branches/proto/v3/boost/xpressive/detail/static/grammar.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/static/grammar.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/static/grammar.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -26,6 +26,24 @@
#include <boost/xpressive/detail/static/static.hpp>
#include <boost/xpressive/detail/static/is_pure.hpp>
+#define CV(T)\
+ typename add_const<T>::type
+
+#define REF(T)\
+ typename add_reference<T>::type
+
+#define CVREF(T)\
+ REF(CV(T))
+
+#define UNCV(T)\
+ typename remove_cv<T>::type
+
+#define UNREF(T)\
+ typename remove_reference<T>::type
+
+#define UNCVREF(T)\
+ UNCV(UNREF(T))
+
#define BOOST_XPRESSIVE_CHECK_REGEX(Expr, Char)\
BOOST_MPL_ASSERT\
((\
@@ -168,7 +186,7 @@
template<typename This, typename T, typename Visitor>
struct result<This(T, Visitor)>
- : Visitor::template apply<T>
+ : remove_reference<Visitor>::type::template apply<UNCVREF(T)>
{};
template<typename T, typename Visitor>
@@ -220,7 +238,7 @@
template<typename This, typename Visitor>
struct result<This(Visitor)>
{
- typedef typename Visitor::traits_type type;
+ typedef UNREF(Visitor)::traits_type const &type;
};
template<typename Visitor>
@@ -239,7 +257,7 @@
template<typename This, typename Traits>
struct result<This(Traits)>
{
- typedef typename Traits::char_class_type type;
+ typedef UNREF(Traits)::char_class_type type;
};
template<typename Traits>
@@ -258,7 +276,7 @@
template<typename This, typename Posix, typename Visitor, typename YesNo>
struct result<This(Posix, Visitor, YesNo)>
{
- typedef posix_charset_matcher<typename Visitor::traits_type> type;
+ typedef posix_charset_matcher<UNREF(Visitor)::traits_type> type;
};
template<typename Posix, typename Visitor>
@@ -289,7 +307,7 @@
template<typename This, typename Matcher, typename Next>
struct result<This(Matcher, Next)>
{
- typedef static_xpression<Matcher, Next> type;
+ typedef static_xpression<UNCVREF(Matcher), UNCVREF(Next)> type;
};
template<typename This, typename Matcher, typename Next, typename Next2>
@@ -306,7 +324,7 @@
}
template<typename Matcher, typename Next, typename Next2>
- static_xpression<Matcher, Next> const &
+ static_xpression<Matcher, Next>
operator()(static_xpression<Matcher, Next> const &xpr, Next2 const &) const
{
return xpr;
@@ -358,7 +376,7 @@
template<typename This, typename Set, typename Expr, typename Visitor>
struct result<This(Set, Expr, Visitor)>
{
- typedef Set type;
+ typedef UNCVREF(Set) type;
};
template<typename Set, typename Expr, typename Visitor>
@@ -398,7 +416,7 @@
template<typename This, typename CharSet, typename Xpr, typename Visitor>
struct result<This(CharSet, Xpr, Visitor)>
{
- typedef CharSet type;
+ typedef CVREF(UNREF(CharSet)) type;
};
template<typename CharSet, typename Traits, typename ICase, typename Not, typename Visitor>
@@ -448,7 +466,7 @@
template<typename This, typename Set>
struct result<This(Set)>
{
- typedef Set type;
+ typedef UNCVREF(Set) type;
};
template<typename Set>
@@ -466,7 +484,7 @@
template<typename This, typename Modifier, typename Visitor>
struct result<This(Modifier, Visitor)>
- : Modifier::template apply<Visitor>
+ : remove_reference<Modifier>::type::template apply<UNCVREF(Visitor)>
{};
template<typename Modifier, typename Visitor>
@@ -1041,4 +1059,11 @@
}} // namespace boost::xpressive
+#undef CV
+#undef REF
+#undef CVREF
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
+
#endif
Modified: branches/proto/v3/boost/xpressive/proto/context/callable.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/context/callable.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/context/callable.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -144,7 +144,7 @@
typename boost::result_of<
Context(
typename Expr::proto_tag
- , typename proto::result_of::arg_c<Expr, Indices>::const_reference...
+ , typename proto::result_of::arg_c<Expr, Indices>::type...
)
>::type
result_type;
Modified: branches/proto/v3/boost/xpressive/proto/context/default.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/context/default.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/context/default.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -28,7 +28,7 @@
#ifndef BOOST_PROTO_DOXYGEN_INVOKED
#define BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL_(Nested, Expr)\
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(BOOST_PP_CAT(nested_and_hidden_, Nested), Expr)\
- static int const sz = sizeof(detail::check_reference(Expr));\
+ static int const sz = sizeof(proto::detail::check_reference(Expr));\
struct Nested\
: mpl::if_c<\
1==sz\
@@ -245,16 +245,9 @@
BOOST_PROTO_BINARY_OP_RESULT(^=, proto::tag::bitwise_xor_assign)
template<typename Expr, typename Context>
-
struct default_eval<Expr, Context, proto::tag::terminal>
{
- typedef
- typename mpl::if_<
- is_const<Expr>
- , typename proto::result_of::arg<Expr>::const_reference
- , typename proto::result_of::arg<Expr>::reference
- >::type
- result_type;
+ typedef typename proto::result_of::arg<Expr>::type result_type;
result_type operator()(Expr &expr, Context &) const
{
Modified: branches/proto/v3/boost/xpressive/proto/deep_copy.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/deep_copy.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/deep_copy.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -43,17 +43,19 @@
};
template<typename... Args>
- argsns_::cons<typename deep_copy_impl<UNCVREF(Args)>::type...>
+ typename result<deep_copy_cons(Args...)>::type
operator()(Args const &... args) const
{
- return argsns_::make_cons(deep_copy_impl<Args>::call(args)...);
+ return result<deep_copy_cons(Args...)>::type::make(
+ deep_copy_impl<Args>::call(args)...
+ );
}
};
template<typename Expr, typename T>
struct deep_copy_impl<Expr, term<T> >
{
- typedef typename terminal<typename result_of::arg<Expr>::type>::type expr_type;
+ typedef typename terminal<UNCVREF(T)>::type expr_type;
typedef typename Expr::proto_domain::template apply<expr_type>::type type;
static type call(Expr const &expr)
Modified: branches/proto/v3/boost/xpressive/proto/fusion.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/fusion.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/fusion.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -121,7 +121,7 @@
template<typename This, typename Expr>
struct result<This(Expr)>
- : fusion::result_of::reverse<Expr const>
+ : fusion::result_of::reverse<UNREF(Expr) const>
{};
template<typename Expr>
@@ -213,7 +213,7 @@
{
template<typename Iterator>
struct apply
- : proto::result_of::arg_c<
+ : proto::result_of::value_at_c<
typename Iterator::expr_type
, Iterator::index
>
@@ -231,9 +231,9 @@
{
typedef
typename proto::result_of::arg_c<
- typename Iterator::expr_type
+ typename Iterator::expr_type const
, Iterator::index
- >::const_reference
+ >::type
type;
static type call(Iterator const &iter)
@@ -369,6 +369,36 @@
};
template<typename Tag>
+ struct value_at_impl;
+
+ template<>
+ struct value_at_impl<proto::tag::proto_expr>
+ {
+ template<typename Sequence, typename Index>
+ struct apply
+ : proto::result_of::value_at_c<Sequence, Index::value>
+ {};
+ };
+
+ template<typename Tag>
+ struct at_impl;
+
+ template<>
+ struct at_impl<proto::tag::proto_expr>
+ {
+ template<typename Sequence, typename Index>
+ struct apply
+ {
+ typedef typename proto::result_of::arg_c<Sequence, Index::value>::type type;
+
+ static type call(Sequence &seq)
+ {
+ return proto::arg_c<Index::value>(seq);
+ }
+ };
+ };
+
+ template<typename Tag>
struct is_segmented_impl;
template<>
@@ -396,10 +426,10 @@
{};
template<typename Expr>
- typename result<as_element(Expr)>::type
+ typename result<as_element(Expr &)>::type
operator()(Expr &expr) const
{
- return typename result<as_element(Expr)>::type(expr);
+ return typename result<as_element(Expr &)>::type(expr);
}
};
Modified: branches/proto/v3/boost/xpressive/proto/make_expr.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/make_expr.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/make_expr.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -481,7 +481,7 @@
{};
template<typename... A>
- typename result_of::make_expr<Tag, Domain, A...>::type const
+ typename result_of::make_expr<Tag, Domain, A...>::type
operator ()(A &&...a) const
{
return result_of::make_expr<Tag, Domain, A...>::call(a...);
Modified: branches/proto/v3/boost/xpressive/proto/matches.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/matches.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/matches.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -366,7 +366,7 @@
template<typename Expr, typename If, typename Then, typename Else>
struct matches_<Expr, proto::if_<If, Then, Else> >
: mpl::eval_if<
- typename boost::result_of<when<_, If>(Expr, mpl::void_, mpl::void_)>::type
+ UNCVREF(typename boost::result_of<otherwise<If>(Expr, mpl::void_, mpl::void_)>::type)
, matches_<Expr, typename Then::proto_base_expr>
, matches_<Expr, typename Else::proto_base_expr>
>::type
@@ -374,7 +374,11 @@
template<typename Expr, typename If>
struct matches_<Expr, proto::if_<If> >
- : boost::result_of<when<_, If>(Expr, mpl::void_, mpl::void_)>::type
+ : remove_cv<
+ typename remove_reference<
+ typename boost::result_of<when<_, If>(Expr, mpl::void_, mpl::void_)>::type
+ >::type
+ >::type
{};
// handle proto::not_
@@ -444,12 +448,12 @@
struct result<This(Expr, State, Visitor)>
{
typedef typename boost::result_of<
- typename detail::which<Expr, Alts...>::type(Expr, State, Visitor)
+ typename detail::which<UNCVREF(Expr), Alts...>::type(Expr, State, Visitor)
>::type type;
};
template<typename Expr, typename State, typename Visitor>
- typename result<or_(Expr, State, Visitor)>::type
+ typename result<or_(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
typedef typename detail::which<Expr, Alts...>::type which;
@@ -475,19 +479,19 @@
template<typename This, typename Expr, typename State, typename Visitor>
struct result<This(Expr, State, Visitor)>
: mpl::eval_if<
- typename boost::result_of<when<_, If>(Expr, State, Visitor)>::type
+ UNCVREF(typename boost::result_of<otherwise<If>(Expr, State, Visitor)>::type)
, boost::result_of<when<_, Then>(Expr, State, Visitor)>
, boost::result_of<when<_, Else>(Expr, State, Visitor)>
>
{};
template<typename Expr, typename State, typename Visitor>
- typename result<if_(Expr, State, Visitor)>::type
+ typename result<if_(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
typedef
typename mpl::if_<
- typename boost::result_of<when<_, If>(Expr, State, Visitor)>::type
+ UNCVREF(typename boost::result_of<otherwise<If>(Expr const &, State const &, Visitor &)>::type)
, when<_, Then>
, when<_, Else>
>::type
@@ -513,11 +517,11 @@
template<typename This, typename Expr, typename State, typename Visitor>
struct result<This(Expr, State, Visitor)>
- : boost::result_of<typename Cases::template case_<typename Expr::proto_tag>(Expr, State, Visitor)>
+ : boost::result_of<typename Cases::template case_<UNREF(Expr)::proto_tag>(Expr, State, Visitor)>
{};
template<typename Expr, typename State, typename Visitor>
- typename result<switch_(Expr, State, Visitor)>::type
+ typename result<switch_(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
typedef typename Cases::template case_<typename Expr::proto_tag> case_;
Modified: branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -163,12 +163,6 @@
namespace result_of
{
- namespace detail
- {
- template<typename Args, long N>
- struct arg_c;
- }
-
template<typename Expr>
struct tag_of
{
@@ -176,6 +170,9 @@
};
template<typename Expr, long N>
+ struct value_at_c;
+
+ template<typename Expr, long N>
struct arg_c;
template<typename Expr>
@@ -216,11 +213,11 @@
using result_of::is_expr;
template<long N, typename Expr>
- typename result_of::arg_c<Expr, N>::reference
+ typename result_of::arg_c<Expr, N>::type
arg_c(Expr &expr);
template<long N, typename Expr>
- typename result_of::arg_c<Expr, N>::const_reference
+ typename result_of::arg_c<Expr const, N>::type
arg_c(Expr const &expr);
template<typename T>
@@ -229,11 +226,6 @@
namespace op
{
- // BUGBUG move this elsewhere
- namespace detail
- {
- }
-
template<typename T> struct terminal;
template<typename T> struct posit;
template<typename T> struct negate;
Modified: branches/proto/v3/boost/xpressive/proto/traits.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/traits.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/traits.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -23,11 +23,14 @@
#define CVREF(T)\
REF(CV(T))
+#define UNCV(T)\
+ typename remove_cv<T>::type
+
#define UNREF(T)\
typename remove_reference<T>::type
#define UNCVREF(T)\
- typename remove_cv<UNREF(T)>::type
+ UNCV(UNREF(T))
namespace boost { namespace proto
{
@@ -146,7 +149,7 @@
template<typename This, typename Expr, typename State, typename Visitor>
struct result<This(Expr, State, Visitor)>
{
- typedef expr<typename Expr::proto_tag, args<
+ typedef expr<UNREF(Expr)::proto_tag, args<
typename boost::result_of<
T(typename result_of::arg_c<Expr, 0>::type, State, Visitor)
>::type
@@ -154,12 +157,12 @@
};
template<typename Expr, typename State, typename Visitor>
- typename result<unary_expr(Expr, State, Visitor)>::type
+ typename result<unary_expr(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- typename result<unary_expr(Expr, State, Visitor)>::type that = {
+ typename result<unary_expr(Expr const &, State const &, Visitor &)>::type that = {{
T()(proto::arg_c<0>(expr), state, visitor)
- };
+ }};
return that;
}
};
@@ -176,17 +179,17 @@
template<typename This, typename Expr, typename State, typename Visitor>
struct result<This(Expr, State, Visitor)>
{
- typedef expr<typename Expr::proto_tag, args<
+ typedef expr<UNREF(Expr)::proto_tag, args<
typename boost::result_of<T(typename result_of::arg_c<Expr, 0>::type, State, Visitor)>::type
, typename boost::result_of<U(typename result_of::arg_c<Expr, 1>::type, State, Visitor)>::type
> > type;
};
template<typename Expr, typename State, typename Visitor>
- typename result<binary_expr(Expr, State, Visitor)>::type
+ typename result<binary_expr(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- typename result<binary_expr(Expr, State, Visitor)>::type that = {{
+ typename result<binary_expr(Expr const &, State const &, Visitor &)>::type that = {{
T()(proto::arg_c<0>(expr), state, visitor)
, {U()(proto::arg_c<1>(expr), state, visitor)}
}};
@@ -251,17 +254,17 @@
template<typename This, typename Expr, typename State, typename Visitor>
struct result<This(Expr, State, Visitor)>
{
- typedef detail::apply_args<args<Args...>, typename Expr::proto_args, State, Visitor> apply;
- typedef expr<typename Expr::proto_tag, typename apply::type> type;
+ typedef detail::apply_args<args<Args...>, UNREF(Expr)::proto_args, State, Visitor> apply_;
+ typedef expr<UNREF(Expr)::proto_tag, typename apply_::type> type;
};
template<typename Expr, typename State, typename Visitor>
- typename result<nary_expr(Expr, State, Visitor)>::type
+ typename result<nary_expr(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- typedef detail::apply_args<args<Args...>, typename Expr::proto_args, State, Visitor> apply;
- typename result<nary_expr(Expr, State, Visitor)>::type that = {
- apply::call(expr.proto_base().proto_args_, state, visitor)
+ typedef result<nary_expr(Expr const &, State const &, Visitor &)> result_;
+ typename result_::type that = {
+ result_::apply_::call(expr.proto_base().proto_args_, state, visitor)
};
return that;
}
@@ -284,76 +287,122 @@
{
typedef arg_c<typename Cons::cdr_type::cdr_type, N-2> base_type;
typedef typename base_type::type type;
- typedef typename base_type::reference reference;
- typedef typename base_type::const_reference const_reference;
- static reference call(Cons &args)
+ static type call(Cons &args)
{
return base_type::call(args.cdr.cdr);
}
+ };
+
+ template<typename Cons>
+ struct arg_c<Cons, 0>
+ {
+ typedef REF(typename Cons::car_type) type;
- static const_reference call(Cons const &args)
+ static type call(Cons &args)
{
- return base_type::call(args.cdr.cdr);
+ return args.car;
}
};
template<typename Cons>
- struct arg_c<Cons, 0>
+ struct arg_c<Cons, 1>
{
- typedef UNCVREF(typename Cons::car_type) type;
- typedef REF(typename Cons::car_type) reference;
- typedef CVREF(typename Cons::car_type) const_reference;
+ typedef REF(typename Cons::cdr_type::car_type) type;
- static reference call(Cons &args)
+ static type call(Cons &args)
{
- return args.car;
+ return args.cdr.car;
}
+ };
+
- static const_reference call(Cons const &args)
+ template<typename Cons, long N>
+ struct arg_cv
+ {
+ typedef arg_cv<typename Cons::cdr_type::cdr_type, N-2> base_type;
+ typedef typename base_type::type type;
+
+ static type call(Cons const &args)
{
- return args.car;
+ return base_type::call(args.cdr.cdr);
}
};
template<typename Cons>
- struct arg_c<Cons, 1>
+ struct arg_cv<Cons, 0>
{
- typedef UNCVREF(typename Cons::cdr_type::car_type) type;
- typedef REF(typename Cons::cdr_type::car_type) reference;
- typedef CVREF(typename Cons::cdr_type::car_type) const_reference;
+ typedef CVREF(typename Cons::car_type) type;
- static reference call(Cons &args)
+ static type call(Cons const &args)
{
- return args.cdr.car;
+ return args.car;
}
+ };
+
+ template<typename Cons>
+ struct arg_cv<Cons, 1>
+ {
+ typedef CVREF(typename Cons::cdr_type::car_type) type;
- static const_reference call(Cons const &args)
+ static type call(Cons const &args)
{
return args.cdr.car;
}
};
+ template<typename Cons, long N>
+ struct value_at_c
+ : value_at_c<typename Cons::cdr_type::cdr_type, N-2>
+ {};
+
+ template<typename Cons>
+ struct value_at_c<Cons, 0>
+ {
+ typedef typename Cons::car_type type;
+ };
+
+ template<typename Cons>
+ struct value_at_c<Cons, 1>
+ {
+ typedef typename Cons::cdr_type::car_type type;
+ };
+
} // namespace detail
template<typename Expr, long N>
+ struct value_at_c
+ : detail::value_at_c<typename Expr::proto_args::cons_type, N>
+ {};
+
+ template<typename Expr, long N>
struct arg_c
: detail::arg_c<typename Expr::proto_args::cons_type, N>
{};
+ template<typename Expr, long N>
+ struct arg_c<Expr const, N>
+ : detail::arg_cv<typename Expr::proto_args::cons_type, N>
+ {};
+
+ template<typename Expr, long N>
+ struct arg_c<Expr &, N>
+ : arg_c<Expr, N>
+ {};
+
template<typename Expr>
struct arg
- : detail::arg_c<typename Expr::proto_args::cons_type, 0>
+ : arg_c<Expr, 0>
{};
template<typename Expr>
struct left
- : detail::arg_c<typename Expr::proto_args::cons_type, 0>
+ : arg_c<Expr, 0>
{};
template<typename Expr>
struct right
- : detail::arg_c<typename Expr::proto_args::cons_type, 1>
+ : arg_c<Expr, 1>
{};
// as_expr
@@ -494,19 +543,21 @@
template<typename This, typename Expr>
struct result<This(Expr)>
- : result_of::arg_c<UNCVREF(Expr), N>
+ : result_of::arg_c<Expr, N>
{};
template<typename Expr>
- typename result_of::arg_c<Expr, N>::reference operator ()(Expr &expr) const
+ typename result_of::arg_c<Expr, N>::type
+ operator ()(Expr &expr) const
{
return result_of::arg_c<Expr, N>::call(expr);
}
template<typename Expr>
- typename result_of::arg_c<Expr, N>::const_reference operator ()(Expr const &expr) const
+ typename result_of::arg_c<Expr const, N>::type
+ operator ()(Expr const &expr) const
{
- return result_of::arg_c<Expr, N>::call(expr);
+ return result_of::arg_c<Expr const, N>::call(expr);
}
};
@@ -543,51 +594,51 @@
}
template<typename Expr>
- typename result_of::arg<Expr>::reference arg(Expr &expr)
+ typename result_of::arg<Expr>::type arg(Expr &expr)
{
return result_of::arg<Expr>::call(expr.proto_base().proto_args_);
}
template<typename Expr>
- typename result_of::arg<Expr>::const_reference arg(Expr const &expr)
+ typename result_of::arg<Expr const>::type arg(Expr const &expr)
{
- return result_of::arg<Expr>::call(expr.proto_base().proto_args_);
+ return result_of::arg<Expr const>::call(expr.proto_base().proto_args_);
}
template<typename Expr>
- typename result_of::left<Expr>::reference left(Expr &expr)
+ typename result_of::left<Expr>::type left(Expr &expr)
{
return result_of::left<Expr>::call(expr.proto_base().proto_args_);
}
template<typename Expr>
- typename result_of::left<Expr>::const_reference left(Expr const &expr)
+ typename result_of::left<Expr const>::type left(Expr const &expr)
{
- return result_of::left<Expr>::call(expr.proto_base().proto_args_);
+ return result_of::left<Expr const>::call(expr.proto_base().proto_args_);
}
template<typename Expr>
- typename result_of::right<Expr>::reference right(Expr &expr)
+ typename result_of::right<Expr>::type right(Expr &expr)
{
return result_of::right<Expr>::call(expr.proto_base().proto_args_);
}
template<typename Expr>
- typename result_of::right<Expr>::const_reference right(Expr const &expr)
+ typename result_of::right<Expr const>::type right(Expr const &expr)
{
- return result_of::right<Expr>::call(expr.proto_base().proto_args_);
+ return result_of::right<Expr const>::call(expr.proto_base().proto_args_);
}
template<long N, typename Expr>
- typename result_of::arg_c<Expr, N>::reference arg_c(Expr &expr)
+ typename result_of::arg_c<Expr, N>::type arg_c(Expr &expr)
{
return result_of::arg_c<Expr, N>::call(expr.proto_base().proto_args_);
}
template<long N, typename Expr>
- typename result_of::arg_c<Expr, N>::const_reference arg_c(Expr const &expr)
+ typename result_of::arg_c<Expr const, N>::type arg_c(Expr const &expr)
{
- return result_of::arg_c<Expr, N>::call(expr.proto_base().proto_args_);
+ return result_of::arg_c<Expr const, N>::call(expr.proto_base().proto_args_);
}
template<typename T>
@@ -707,6 +758,7 @@
#undef CV
#undef REF
#undef CVREF
+#undef UNCV
#undef UNREF
#undef UNCVREF
Modified: branches/proto/v3/boost/xpressive/proto/transform/arg.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/arg.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/arg.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -87,7 +87,7 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename boost::proto::result_of::arg_c<Expr, I>::const_reference
+ typename proto::result_of::arg_c<Expr const &, I>::type
operator()(Expr const &expr, State const &, Visitor &) const
{
return proto::arg_c<I>(expr);
Modified: branches/proto/v3/boost/xpressive/proto/transform/bind.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/bind.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/bind.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -36,11 +36,11 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename result<bind(Expr, State, Visitor)>::type
+ typename result<bind(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
return call<
- typename boost::result_of<make<Return>(Expr, State, Visitor)>::type
+ typename boost::result_of<make<Return>(Expr const &, State const &, Visitor &)>::type
, Args...
>()(expr, state, visitor);
}
Modified: branches/proto/v3/boost/xpressive/proto/transform/call.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/call.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/call.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -13,6 +13,24 @@
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/traits.hpp>
+#define CV(T)\
+ typename add_const<T>::type
+
+#define REF(T)\
+ typename add_reference<T>::type
+
+#define CVREF(T)\
+ REF(CV(T))
+
+#define UNCV(T)\
+ typename remove_cv<T>::type
+
+#define UNREF(T)\
+ typename remove_reference<T>::type
+
+#define UNCVREF(T)\
+ UNCV(UNREF(T))
+
namespace boost { namespace proto
{
@@ -80,7 +98,7 @@
struct arity1
{
static callable1_wrap<Fun> &fun;
- static A0 &a0;
+ static REF(A0) a0;
static int const value =
sizeof(yes_type) == sizeof(check_fun_arity((fun(a0), 0)))
@@ -92,8 +110,8 @@
struct arity2
{
static callable2_wrap<Fun> &fun;
- static A0 &a0;
- static A1 &a1;
+ static REF(A0) a0;
+ static REF(A1) a1;
static int const value =
sizeof(yes_type) == sizeof(check_fun_arity((fun(a0, a1), 0)))
@@ -186,7 +204,7 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename result<call(Expr, State, Visitor)>::type
+ typename result<call(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
Fun f;
@@ -211,10 +229,10 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename result<call(Expr, State, Visitor)>::type
+ typename result<call(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- return result<call(Expr, State, Visitor)>::call(
+ return result<call(Expr const &, State const &, Visitor &)>::call(
expr
, state
, visitor
@@ -239,10 +257,10 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename result<call(Expr, State, Visitor)>::type
+ typename result<call(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- return result<call(Expr, State, Visitor)>::call(
+ return result<call(Expr const &, State const &, Visitor &)>::call(
when<_, Arg0>()(expr, state, visitor)
, state
, visitor
@@ -267,10 +285,10 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename result<call(Expr, State, Visitor)>::type
+ typename result<call(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- return result<call(Expr, State, Visitor)>::call(
+ return result<call(Expr const &, State const &, Visitor &)>::call(
when<_, Arg0>()(expr, state, visitor)
, when<_, Arg1>()(expr, state, visitor)
, visitor
@@ -296,7 +314,7 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename result<call(Expr, State, Visitor)>::type
+ typename result<call(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
Fun f;
@@ -322,4 +340,11 @@
}}
+#undef CV
+#undef REF
+#undef CVREF
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
+
#endif
Modified: branches/proto/v3/boost/xpressive/proto/transform/fold.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/fold.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/fold.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -44,11 +44,11 @@
template<typename This, typename Expr, typename State>
struct result<This(Expr, State)>
- : boost::result_of<Tfx(UNCVREF(Expr), UNCVREF(State), Visitor)>
+ : boost::result_of<Tfx(Expr, State, Visitor &)>
{};
template<typename Expr, typename State>
- typename boost::result_of<Tfx(Expr, State, Visitor)>::type
+ typename boost::result_of<Tfx(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state) const
{
return Tfx()(expr, state, this->v_);
@@ -60,11 +60,12 @@
struct reverse : transform_base
{
- template<typename Sig> struct result;
+ template<typename Sig>
+ struct result;
template<typename This, typename T>
struct result<This(T)>
- : fusion::result_of::reverse<T const>
+ : fusion::result_of::reverse<UNREF(T) const>
{};
template<typename T>
@@ -86,14 +87,14 @@
template<typename This, typename Expr, typename State, typename Visitor>
struct result<This(Expr, State, Visitor)>
: fusion::result_of::fold<
- typename boost::result_of<when<_, Sequence>(Expr, State, Visitor)>::type
- , typename boost::result_of<when<_, State0>(Expr, State, Visitor)>::type
- , detail::as_callable<Fun, Visitor>
+ UNREF(typename boost::result_of<otherwise<Sequence>(Expr, State, Visitor)>::type)
+ , UNCVREF(typename boost::result_of<otherwise<State0>(Expr, State, Visitor)>::type)
+ , detail::as_callable<Fun, UNREF(Visitor)>
>
{};
template<typename Expr, typename State, typename Visitor>
- typename result<fold(Expr, State, Visitor)>::type
+ typename result<fold(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
detail::as_callable<Fun, Visitor> fun(visitor);
Modified: branches/proto/v3/boost/xpressive/proto/transform/fold_tree.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/fold_tree.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/fold_tree.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -15,6 +15,24 @@
#include <boost/xpressive/proto/traits.hpp>
#include <boost/xpressive/proto/transform/fold.hpp>
+#define CV(T)\
+ typename add_const<T>::type
+
+#define REF(T)\
+ typename add_reference<T>::type
+
+#define CVREF(T)\
+ REF(CV(T))
+
+#define UNCV(T)\
+ typename remove_cv<T>::type
+
+#define UNREF(T)\
+ typename remove_reference<T>::type
+
+#define UNCVREF(T)\
+ UNCV(UNREF(T))
+
namespace boost { namespace proto
{
@@ -55,7 +73,7 @@
Sequence
, State0
, detail::fold_tree_<
- nary_expr<typename Expr::proto_tag, vararg<_> >
+ nary_expr<UNREF(Expr)::proto_tag, vararg<_> >
, Fun
>
> impl;
@@ -64,10 +82,10 @@
};
template<typename Expr, typename State, typename Visitor>
- typename result<fold_tree(Expr, State, Visitor)>::type
+ typename result<fold_tree(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- typedef typename result<fold_tree(Expr, State, Visitor)>::impl impl;
+ typedef typename result<fold_tree(Expr const &, State const &, Visitor &)>::impl impl;
return impl()(expr, state, visitor);
}
};
@@ -86,7 +104,7 @@
Sequence
, State0
, detail::reverse_fold_tree_<
- nary_expr<typename Expr::proto_tag, vararg<_> >
+ nary_expr<UNREF(Expr)::proto_tag, vararg<_> >
, Fun
>
> impl;
@@ -95,10 +113,10 @@
};
template<typename Expr, typename State, typename Visitor>
- typename result<reverse_fold_tree(Expr, State, Visitor)>::type
+ typename result<reverse_fold_tree(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- typedef typename result<reverse_fold_tree(Expr, State, Visitor)>::impl impl;
+ typedef typename result<reverse_fold_tree(Expr const &, State const &, Visitor &)>::impl impl;
return impl()(expr, state, visitor);
}
};
@@ -125,4 +143,11 @@
{};
}}
+#undef CV
+#undef REF
+#undef CVREF
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
+
#endif
Modified: branches/proto/v3/boost/xpressive/proto/transform/make.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/make.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/make.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -80,17 +80,23 @@
template<typename R, typename Expr, typename State, typename Visitor>
struct make_if_<R, Expr, State, Visitor, true>
- : boost::result_of<R(Expr, State, Visitor)>
+ : remove_const<typename remove_reference<
+ typename boost::result_of<R(Expr, State, Visitor)>::type
+ >::type>
{};
template<typename R, typename... Args, typename Expr, typename State, typename Visitor>
struct make_if_<R(Args...), Expr, State, Visitor, false>
- : boost::result_of<when<_, R(Args...)>(Expr, State, Visitor)>
+ : remove_const<typename remove_reference<
+ typename boost::result_of<when<_, R(Args...)>(Expr, State, Visitor)>::type
+ >::type>
{};
template<typename R, typename... Args, typename Expr, typename State, typename Visitor>
struct make_if_<R(*)(Args...), Expr, State, Visitor, false>
- : boost::result_of<when<_, R(Args...)>(Expr, State, Visitor)>
+ : remove_const<typename remove_reference<
+ typename boost::result_of<when<_, R(Args...)>(Expr, State, Visitor)>::type
+ >::type>
{};
// work around GCC bug
@@ -162,10 +168,10 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename result<make(Expr, State, Visitor)>::type
+ typename result<make(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
- typedef typename result<make(Expr, State, Visitor)>::type result_type;
+ typedef typename result<make(Expr const &, State const &, Visitor &)>::type result_type;
return detail::construct<result_type>(when<_, Args>()(expr, state, visitor)...);
}
};
Modified: branches/proto/v3/boost/xpressive/proto/transform/when.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/when.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/when.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -55,7 +55,7 @@
{};
template<typename Expr, typename State, typename Visitor>
- typename result<when(Expr, State, Visitor)>::type
+ typename result<when(Expr const &, State const &, Visitor &)>::type
operator()(Expr const &expr, State const &state, Visitor &visitor) const
{
return typename mpl::if_<
Modified: branches/proto/v3/boost/xpressive/regex_actions.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/regex_actions.hpp (original)
+++ branches/proto/v3/boost/xpressive/regex_actions.hpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -94,7 +94,7 @@
template<typename This, typename Expr, typename State, typename Visitor>
struct result<This(Expr, State, Visitor)>
{
- typedef State type;
+ typedef UNCVREF(State) type;
};
template<typename Expr, typename State, typename Visitor>
Modified: branches/proto/v3/libs/xpressive/proto/example/lazy_vector.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto/example/lazy_vector.cpp (original)
+++ branches/proto/v3/libs/xpressive/proto/example/lazy_vector.cpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -55,7 +55,7 @@
template<typename Expr>
struct eval<Expr, proto::tag::terminal>
{
- typedef typename proto::result_of::arg<Expr>::type::value_type result_type;
+ typedef typename proto::result_of::value_at_c<Expr, 0>::type::value_type result_type;
result_type operator()( Expr const & expr, lazy_subscript_context & ctx ) const
{
Modified: branches/proto/v3/libs/xpressive/proto/example/mixed.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto/example/mixed.cpp (original)
+++ branches/proto/v3/libs/xpressive/proto/example/mixed.cpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -29,6 +29,15 @@
template<typename Expr>
struct MixedExpr;
+template<typename T>
+struct arg
+ : remove_cv<
+ typename remove_reference<
+ typename proto::result_of::value_at_c<T, 0>::type
+ >::type
+ >
+{};
+
template<typename Iter>
struct iterator_wrapper
{
@@ -41,13 +50,18 @@
struct begin : proto::transform_base
{
- template<class Sig> struct result;
+ template<class Sig>
+ struct result;
+
template<class This, class Cont>
struct result<This(Cont)>
- : proto::result_of::as_expr<iterator_wrapper<typename Cont::const_iterator> >
+ : proto::result_of::as_expr<
+ iterator_wrapper<typename remove_reference<Cont>::type::const_iterator>
+ >
{};
+
template<typename Cont>
- typename proto::result_of::as_expr<iterator_wrapper<typename Cont::const_iterator> >::type
+ typename result<begin(Cont const &)>::type
operator()(Cont const &cont) const
{
iterator_wrapper<typename Cont::const_iterator> it(cont.begin());
@@ -72,7 +86,7 @@
{
// Unless this is a vector terminal, use the
// default evaluation context
- template<typename Expr, typename Arg = typename proto::result_of::arg<Expr>::type>
+ template<typename Expr, typename Arg = typename arg<Expr>::type>
struct eval
: proto::default_eval<Expr, DereferenceCtx const>
{};
@@ -96,7 +110,7 @@
{
// Unless this is a vector terminal, use the
// default evaluation context
- template<typename Expr, typename Arg = typename proto::result_of::arg<Expr>::type>
+ template<typename Expr, typename Arg = typename arg<Expr>::type>
struct eval
: proto::null_eval<Expr, IncrementCtx const>
{};
Modified: branches/proto/v3/libs/xpressive/proto/example/vector.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto/example/vector.cpp (original)
+++ branches/proto/v3/libs/xpressive/proto/example/vector.cpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -21,6 +21,15 @@
template<typename Expr>
struct VectorExpr;
+template<typename T>
+struct arg
+ : remove_cv<
+ typename remove_reference<
+ typename proto::result_of::value_at_c<T, 0>::type
+ >::type
+ >
+{};
+
// Here is an evaluation context that indexes into a std::vector
// expression and combines the result.
struct VectorSubscriptCtx
@@ -31,7 +40,7 @@
// Unless this is a vector terminal, use the
// default evaluation context
- template<typename Expr, typename Arg = typename proto::result_of::arg<Expr>::type>
+ template<typename Expr, typename Arg = typename arg<Expr>::type>
struct eval
: proto::default_eval<Expr, VectorSubscriptCtx const>
{};
@@ -61,7 +70,7 @@
// Unless this is a vector terminal, use the
// null evaluation context
- template<typename Expr, typename Arg = typename proto::result_of::arg<Expr>::type>
+ template<typename Expr, typename Arg = typename arg<Expr>::type>
struct eval
: proto::null_eval<Expr, VectorSizeCtx const>
{};
Modified: branches/proto/v3/libs/xpressive/proto/test/examples.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto/test/examples.cpp (original)
+++ branches/proto/v3/libs/xpressive/proto/test/examples.cpp 2007-12-08 18:17:30 EST (Sat, 08 Dec 2007)
@@ -81,14 +81,14 @@
};
template<typename Expr, typename State, typename Visitor>
- typename result<unary_arity(Expr, State, Visitor)>::type
+ typename result<unary_arity(Expr const &, State const &, Visitor &)>::type
/*<< Transforms have a nested `operator()` member function. >>*/
operator()(Expr const &, State const &, Visitor &) const
{
/*<< The `unary_arity` transform doesn't have an interesting
runtime counterpart, so just return a default-constructed object
of the correct type. >>*/
- return typename result<unary_arity(Expr, State, Visitor)>::type();
+ return typename result<unary_arity(Expr const &, State const &, Visitor &)>::type();
}
};
@@ -122,14 +122,14 @@
};
template<typename Expr, typename State, typename Visitor>
- typename result<binary_arity(Expr, State, Visitor)>::type
+ typename result<binary_arity(Expr const &, State const &, Visitor &)>::type
/*<< Transforms have a nested `call()` member function. >>*/
operator()(Expr const &, State const &, Visitor &) const
{
/*<< The `binary_arity` transform doesn't have an interesting
runtime counterpart, so just return a default-constructed object
of the correct type. >>*/
- return typename result<binary_arity(Expr, State, Visitor)>::type();
+ return typename result<binary_arity(Expr const &, State const &, Visitor &)>::type();
}
};
//]
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