|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2007-12-22 14:48:48
Author: eric_niebler
Date: 2007-12-22 14:48:47 EST (Sat, 22 Dec 2007)
New Revision: 42245
URL: http://svn.boost.org/trac/boost/changeset/42245
Log:
port operators.hpp to c++03
Text files modified:
branches/proto/v3/boost/xpressive/proto/detail/make_arg_expr_.hpp | 2
branches/proto/v3/boost/xpressive/proto/expr.hpp | 9 +
branches/proto/v3/boost/xpressive/proto/operators.hpp | 268 ++++++++++++++++++++++++++++++++++++++-
branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp | 18 ++
branches/proto/v3/libs/xpressive/proto/test/matches.cpp | 1
5 files changed, 282 insertions(+), 16 deletions(-)
Modified: branches/proto/v3/boost/xpressive/proto/detail/make_arg_expr_.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/detail/make_arg_expr_.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/detail/make_arg_expr_.hpp 2007-12-22 14:48:47 EST (Sat, 22 Dec 2007)
@@ -27,7 +27,7 @@
: proto::detail::make_<Tag, typename domain_of<A0>::type, functional::as_expr, A0>
{};
- #define BOOST_PP_ITERATION_PARAMS_1 (3, (2, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/detail/make_arg_expr_.hpp>))
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (2, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), <boost/xpressive/proto/detail/make_arg_expr_.hpp>))
#include BOOST_PP_ITERATE()
#else
Modified: branches/proto/v3/boost/xpressive/proto/expr.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/expr.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/expr.hpp 2007-12-22 14:48:47 EST (Sat, 22 Dec 2007)
@@ -245,6 +245,13 @@
return that;
}
#else
+ template<typename Expr, typename A>
+ Expr construct(A &a BOOST_PROTO_DISABLE_IF_IS_CONST(A))
+ {
+ typedef typename Expr::proto_args::cons_type cons_type;
+ Expr that = {proto::argsns_::make_cons_<cons_type>(a)};
+ return that;
+ }
#define TMP(Z, N, DATA) \
template<typename Expr BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, typename A)> \
inline Expr construct(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) \
@@ -254,7 +261,7 @@
return that; \
} \
/**/
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
+ BOOST_PP_REPEAT_FROM_TO(2, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
#undef TMP
#endif
}
Modified: branches/proto/v3/boost/xpressive/proto/operators.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/operators.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/operators.hpp 2007-12-22 14:48:47 EST (Sat, 22 Dec 2007)
@@ -151,6 +151,7 @@
#define BOOST_PROTO_UNARY_OP_IS_POSTFIX_0
#define BOOST_PROTO_UNARY_OP_IS_POSTFIX_1 , int
+#ifdef BOOST_HAS_RVALUE_REFS
#define BOOST_PROTO_DEFINE_UNARY_OPERATOR(OP, TAG, POST) \
template<typename A> \
typename detail::generate_if< \
@@ -167,8 +168,7 @@
typename result_of::as_expr_ref<A, D>::type \
> > that = {{result_of::as_expr_ref<A, D>::call(a)}}; \
return D::make(that); \
- } \
- /**/
+ }
#define BOOST_PROTO_DEFINE_BINARY_OPERATOR(OP, TAG) \
template<typename A, typename B> \
@@ -191,8 +191,128 @@
, {result_of::as_expr_ref<B, D>::call(b)}} \
}; \
return D::make(that); \
+ }
+#else
+ #define BOOST_PROTO_DEFINE_UNARY_OPERATOR(OP, TAG, POST) \
+ template<typename A> \
+ typename detail::generate_if< \
+ true \
+ , typename A::proto_domain \
+ , expr<TAG, args< \
+ typename result_of::as_expr_ref<A &, typename A::proto_domain>::type \
+ > > \
+ >::type const \
+ operator OP(A &a BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
+ { \
+ typedef typename A::proto_domain D; \
+ expr<TAG, args< \
+ typename result_of::as_expr_ref<A &, D>::type \
+ > > that = {{result_of::as_expr_ref<A &, D>::call(a)}}; \
+ return D::make(that); \
+ } \
+ template<typename A> \
+ typename detail::generate_if< \
+ true \
+ , typename A::proto_domain \
+ , expr<TAG, args< \
+ typename result_of::as_expr_ref<A const &, typename A::proto_domain>::type \
+ > > \
+ >::type const \
+ operator OP(A const &a BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
+ { \
+ typedef typename A::proto_domain D; \
+ expr<TAG, args< \
+ typename result_of::as_expr_ref<A const &, D>::type \
+ > > that = {{result_of::as_expr_ref<A const &, D>::call(a)}}; \
+ return D::make(that); \
+ }
+
+ #define BOOST_PROTO_DEFINE_BINARY_OPERATOR(OP, TAG) \
+ template<typename A, typename B> \
+ typename detail::generate_if< \
+ result_of::is_expr<A>::value || result_of::is_expr<B>::value \
+ , typename detail::unify_domain<A, B>::type \
+ , expr<TAG, args< \
+ typename result_of::as_expr_ref<A &, typename detail::unify_domain<A, B>::type>::type\
+ , typename result_of::as_expr_ref<B &, typename detail::unify_domain<A, B>::type>::type\
+ > > \
+ >::type const \
+ operator OP(A &a, B &b) \
+ { \
+ typedef typename detail::unify_domain<A, B>::type D; \
+ expr<TAG, args< \
+ typename result_of::as_expr_ref<A &, D>::type \
+ , typename result_of::as_expr_ref<B &, D>::type \
+ > > that = { \
+ {result_of::as_expr_ref<A &, D>::call(a) \
+ , {result_of::as_expr_ref<B &, D>::call(b)}} \
+ }; \
+ return D::make(that); \
} \
- /**/
+ template<typename A, typename B> \
+ typename detail::generate_if< \
+ result_of::is_expr<A>::value || result_of::is_expr<B>::value \
+ , typename detail::unify_domain<A, B>::type \
+ , expr<TAG, args< \
+ typename result_of::as_expr_ref<A &, typename detail::unify_domain<A, B>::type>::type\
+ , typename result_of::as_expr_ref<B const &, typename detail::unify_domain<A, B>::type>::type\
+ > > \
+ >::type const \
+ operator OP(A &a, B const &b) \
+ { \
+ typedef typename detail::unify_domain<A, B>::type D; \
+ expr<TAG, args< \
+ typename result_of::as_expr_ref<A &, D>::type \
+ , typename result_of::as_expr_ref<B const &, D>::type \
+ > > that = { \
+ {result_of::as_expr_ref<A &, D>::call(a) \
+ , {result_of::as_expr_ref<B const &, D>::call(b)}} \
+ }; \
+ return D::make(that); \
+ } \
+ template<typename A, typename B> \
+ typename detail::generate_if< \
+ result_of::is_expr<A>::value || result_of::is_expr<B>::value \
+ , typename detail::unify_domain<A, B>::type \
+ , expr<TAG, args< \
+ typename result_of::as_expr_ref<A const &, typename detail::unify_domain<A, B>::type>::type\
+ , typename result_of::as_expr_ref<B &, typename detail::unify_domain<A, B>::type>::type\
+ > > \
+ >::type const \
+ operator OP(A const &a, B &b) \
+ { \
+ typedef typename detail::unify_domain<A, B>::type D; \
+ expr<TAG, args< \
+ typename result_of::as_expr_ref<A const &, D>::type \
+ , typename result_of::as_expr_ref<B &, D>::type \
+ > > that = { \
+ {result_of::as_expr_ref<A const &, D>::call(a) \
+ , {result_of::as_expr_ref<B &, D>::call(b)}} \
+ }; \
+ return D::make(that); \
+ } \
+ template<typename A, typename B> \
+ typename detail::generate_if< \
+ result_of::is_expr<A>::value || result_of::is_expr<B>::value \
+ , typename detail::unify_domain<A, B>::type \
+ , expr<TAG, args< \
+ typename result_of::as_expr_ref<A const &, typename detail::unify_domain<A, B>::type>::type\
+ , typename result_of::as_expr_ref<B const &, typename detail::unify_domain<A, B>::type>::type\
+ > > \
+ >::type const \
+ operator OP(A const &a, B const &b) \
+ { \
+ typedef typename detail::unify_domain<A, B>::type D; \
+ expr<TAG, args< \
+ typename result_of::as_expr_ref<A const &, D>::type \
+ , typename result_of::as_expr_ref<B const &, D>::type \
+ > > that = { \
+ {result_of::as_expr_ref<A const &, D>::call(a) \
+ , {result_of::as_expr_ref<B const &, D>::call(b)}} \
+ }; \
+ return D::make(that); \
+ }
+#endif
BOOST_PROTO_DEFINE_UNARY_OPERATOR(+, tag::posit, 0)
BOOST_PROTO_DEFINE_UNARY_OPERATOR(-, tag::negate, 0)
@@ -240,28 +360,80 @@
#undef BOOST_PROTO_DEFINE_UNARY_OPERATOR
#undef BOOST_PROTO_DEFINE_BINARY_OPERATOR
+ #ifdef BOOST_HAS_RVALUE_REFS
template<typename A, typename B, typename C>
typename result_of::make_expr_ref<tag::if_else_, A, B, C>::type const
if_else(A &&a, B &&b, C &&c)
{
return result_of::make_expr_ref<tag::if_else_, A, B, C>::call(a, b, c);
}
+ #else
+ template<typename A, typename B, typename C>
+ typename result_of::make_expr_ref<tag::if_else_, A &, B &, C &>::type const
+ if_else(A &a, B &b, C &c)
+ {
+ return result_of::make_expr_ref<tag::if_else_, A &, B &, C &>::call(a, b, c);
+ }
+ template<typename A, typename B, typename C>
+ typename result_of::make_expr_ref<tag::if_else_, A &, B &, C const &>::type const
+ if_else(A &a, B &b, C const &c)
+ {
+ return result_of::make_expr_ref<tag::if_else_, A &, B &, C const &>::call(a, b, c);
+ }
+ template<typename A, typename B, typename C>
+ typename result_of::make_expr_ref<tag::if_else_, A &, B const &, C &>::type const
+ if_else(A &a, B const &b, C &c)
+ {
+ return result_of::make_expr_ref<tag::if_else_, A &, B const &, C &>::call(a, b, c);
+ }
+ template<typename A, typename B, typename C>
+ typename result_of::make_expr_ref<tag::if_else_, A &, B const &, C const &>::type const
+ if_else(A &a, B const &b, C const &c)
+ {
+ return result_of::make_expr_ref<tag::if_else_, A &, B const &, C const &>::call(a, b, c);
+ }
+ template<typename A, typename B, typename C>
+ typename result_of::make_expr_ref<tag::if_else_, A const &, B &, C &>::type const
+ if_else(A const &a, B &b, C &c)
+ {
+ return result_of::make_expr_ref<tag::if_else_, A const &, B &, C &>::call(a, b, c);
+ }
+ template<typename A, typename B, typename C>
+ typename result_of::make_expr_ref<tag::if_else_, A const &, B &, C const &>::type const
+ if_else(A const &a, B &b, C const &c)
+ {
+ return result_of::make_expr_ref<tag::if_else_, A const &, B &, C const &>::call(a, b, c);
+ }
+ template<typename A, typename B, typename C>
+ typename result_of::make_expr_ref<tag::if_else_, A const &, B const &, C &>::type const
+ if_else(A const &a, B const &b, C &c)
+ {
+ return result_of::make_expr_ref<tag::if_else_, A const &, B const &, C &>::call(a, b, c);
+ }
+ template<typename A, typename B, typename C>
+ typename result_of::make_expr_ref<tag::if_else_, A const &, B const &, C const &>::type const
+ if_else(A const &a, B const &b, C const &c)
+ {
+ return result_of::make_expr_ref<tag::if_else_, A const &, B const &, C const &>::call(a, b, c);
+ }
+ #endif
+
}
using exprns_::if_else;
+#ifdef BOOST_HAS_RVALUE_REFS
#define BOOST_PROTO_DEFINE_UNARY_OPERATOR(OP, TAG, TRAIT, DOMAIN, POST) \
template<typename Arg> \
typename boost::proto::exprns_::detail::enable_unary< \
DOMAIN \
, TRAIT<BOOST_PROTO_UNCVREF(Arg)>, Arg \
- , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Arg>::type \
- >::type const \
+ , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Arg>::type \
+ >::type const \
operator OP(Arg &&arg BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
{ \
- return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Arg>::call(arg); \
- } \
- /**/
+ return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Arg>::call(arg); \
+ }
#define BOOST_PROTO_DEFINE_BINARY_OPERATOR(OP, TAG, TRAIT, DOMAIN) \
template<typename Left, typename Right> \
@@ -269,14 +441,86 @@
DOMAIN \
, TRAIT<BOOST_PROTO_UNCVREF(Left)>, Left \
, TRAIT<BOOST_PROTO_UNCVREF(Right)>, Right \
- , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left, Right>::type \
+ , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left, Right>::type \
>::type const \
operator OP(Left &&left, Right &&right) \
{ \
- return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left, Right> \
+ return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left, Right> \
+ ::call(left, right); \
+ }
+#else
+#define BOOST_PROTO_DEFINE_UNARY_OPERATOR(OP, TAG, TRAIT, DOMAIN, POST) \
+ template<typename Arg> \
+ typename boost::proto::exprns_::detail::enable_unary< \
+ DOMAIN \
+ , TRAIT<Arg>, Arg & \
+ , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Arg &>::type \
+ >::type const \
+ operator OP(Arg &arg BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
+ { \
+ return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Arg &>::call(arg); \
+ } \
+ template<typename Arg> \
+ typename boost::proto::exprns_::detail::enable_unary< \
+ DOMAIN \
+ , TRAIT<Arg>, Arg const & \
+ , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Arg const &>::type \
+ >::type const \
+ operator OP(Arg const &arg BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
+ { \
+ return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Arg const &>::call(arg); \
+ }
+
+#define BOOST_PROTO_DEFINE_BINARY_OPERATOR(OP, TAG, TRAIT, DOMAIN) \
+ template<typename Left, typename Right> \
+ typename boost::proto::exprns_::detail::enable_binary< \
+ DOMAIN \
+ , TRAIT<Left>, Left & \
+ , TRAIT<Right>, Right & \
+ , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left &, Right &>::type \
+ >::type const \
+ operator OP(Left &left, Right &right) \
+ { \
+ return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left &, Right &> \
::call(left, right); \
} \
- /**/
+ template<typename Left, typename Right> \
+ typename boost::proto::exprns_::detail::enable_binary< \
+ DOMAIN \
+ , TRAIT<Left>, Left & \
+ , TRAIT<Right>, Right const & \
+ , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left &, Right const &>::type \
+ >::type const \
+ operator OP(Left &left, Right const &right) \
+ { \
+ return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left &, Right const &> \
+ ::call(left, right); \
+ } \
+ template<typename Left, typename Right> \
+ typename boost::proto::exprns_::detail::enable_binary< \
+ DOMAIN \
+ , TRAIT<Left>, Left const & \
+ , TRAIT<Right>, Right & \
+ , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left const &, Right &>::type \
+ >::type const \
+ operator OP(Left const &left, Right &right) \
+ { \
+ return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left const &, Right &> \
+ ::call(left, right); \
+ } \
+ template<typename Left, typename Right> \
+ typename boost::proto::exprns_::detail::enable_binary< \
+ DOMAIN \
+ , TRAIT<Left>, Left const & \
+ , TRAIT<Right>, Right const & \
+ , typename boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left const &, Right const &>::type\
+ >::type const \
+ operator OP(Left const &left, Right const &right) \
+ { \
+ return boost::proto::result_of::make_expr_ref<TAG, DOMAIN, Left const &, Right const &> \
+ ::call(left, right); \
+ }
+#endif
#define BOOST_PROTO_DEFINE_OPERATORS(TRAIT, DOMAIN) \
BOOST_PROTO_DEFINE_UNARY_OPERATOR(+, boost::proto::tag::posit, TRAIT, DOMAIN, 0) \
@@ -328,7 +572,7 @@
namespace exops
{
- BOOST_PROTO_DEFINE_OPERATORS(is_extension, default_domain)
+// BOOST_PROTO_DEFINE_OPERATORS(is_extension, default_domain)
using proto::if_else;
}
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-22 14:48:47 EST (Sat, 22 Dec 2007)
@@ -26,6 +26,20 @@
# define BOOST_PROTO_MAX_LOGICAL_ARITY 8
#endif
+#if BOOST_WORKAROUND(__GNUC__, == 3) \
+ || BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306))
+# define BOOST_PROTO_BROKEN_CONST_OVERLOADS
+#endif
+
+#ifdef BOOST_PROTO_BROKEN_CONST_OVERLOADS
+# include <boost/utility/enable_if.hpp>
+# include <boost/type_traits/is_const.hpp>
+# define BOOST_PROTO_DISABLE_IF_IS_CONST(T)\
+ , typename boost::disable_if<boost::is_const<T> >::type * = 0
+#else
+# define BOOST_PROTO_DISABLE_IF_IS_CONST(T)
+#endif
+
namespace boost { namespace proto
{
namespace detail
@@ -119,11 +133,13 @@
template<typename Expr, typename... A>
Expr construct(A &... a);
#else
+ template<typename Expr, typename A>
+ Expr construct(A &a BOOST_PROTO_DISABLE_IF_IS_CONST(A));
#define TMP(Z, N, DATA) \
template<typename Expr BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, typename A)> \
Expr construct(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)); \
/**/
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
+ BOOST_PP_REPEAT_FROM_TO(2, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
#undef TMP
#endif
Modified: branches/proto/v3/libs/xpressive/proto/test/matches.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto/test/matches.cpp (original)
+++ branches/proto/v3/libs/xpressive/proto/test/matches.cpp 2007-12-22 14:48:47 EST (Sat, 22 Dec 2007)
@@ -11,7 +11,6 @@
#include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform.hpp>
#include <boost/test/unit_test.hpp>
using namespace boost;
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