Update of /cvsroot/boost/boost/boost/xpressive/proto
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16056/proto
Modified Files:
domain.hpp make_expr.hpp proto_fwd.hpp
Log Message:
add proto::deduce_domain, make it the default for proto::make_expr and friends
Index: domain.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/domain.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- domain.hpp 26 May 2007 00:53:57 -0000 1.3
+++ domain.hpp 27 May 2007 03:56:20 -0000 1.4
@@ -13,6 +13,7 @@
#include <boost/xpressive/proto/detail/prefix.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/xpressive/proto/proto_fwd.hpp>
+#include <boost/xpressive/proto/generate.hpp>
#include <boost/xpressive/proto/detail/suffix.hpp>
namespace boost { namespace proto
@@ -29,6 +30,10 @@
typedef void boost_proto_is_domain_;
};
+ struct deduce_domain
+ : domain<>
+ {};
+
template<typename T, typename EnableIf>
struct is_domain
: mpl::false_
@@ -39,6 +44,18 @@
: mpl::true_
{};
+ template<typename T, typename EnableIf>
+ struct domain_of
+ {
+ typedef default_domain type;
+ };
+
+ template<typename T>
+ struct domain_of<T, typename T::is_boost_proto_expr_>
+ {
+ typedef typename T::domain type;
+ };
+
}}
#endif
Index: make_expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/make_expr.hpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- make_expr.hpp 26 May 2007 00:53:57 -0000 1.16
+++ make_expr.hpp 27 May 2007 03:56:20 -0000 1.17
@@ -13,6 +13,8 @@
#include <boost/xpressive/proto/detail/prefix.hpp>
#include <boost/preprocessor/cat.hpp>
+ #include <boost/preprocessor/arithmetic/dec.hpp>
+ #include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/iterate.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
@@ -21,6 +23,7 @@
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
+ #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/ref.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
@@ -49,17 +52,25 @@
/**/
#define BOOST_PROTO_AT_TYPE(Z, N, DATA)
\
+ typename remove_reference<
\
+ typename fusion::result_of::value_at_c<BOOST_PP_TUPLE_ELEM(2, 0,
DATA), N >::type \
+ >::type
\
+ /**/
+
+ #define BOOST_PROTO_AT(Z, N, DATA)
\
+ fusion::at_c<N >(BOOST_PP_TUPLE_ELEM(2, 0, DATA))
\
+ /**/
+
+ #define BOOST_PROTO_AS_ARG_AT_TYPE(Z, N, DATA)
\
typename result_of::as_arg<
\
- typename remove_reference<
\
- typename fusion::result_of::value_at_c<BOOST_PP_TUPLE_ELEM(2,
0, DATA), N >::type \
- >::type
\
+ BOOST_PROTO_AT_TYPE(Z, N, DATA)
\
, BOOST_PP_TUPLE_ELEM(2, 1, DATA)
\
>::type
\
/**/
- #define BOOST_PROTO_AT(Z, N, DATA)
\
+ #define BOOST_PROTO_AS_ARG_AT(Z, N, DATA)
\
proto::as_arg<BOOST_PP_TUPLE_ELEM(2, 1, DATA) >(
\
- fusion::at_c<N >(BOOST_PP_TUPLE_ELEM(2, 0, DATA))
\
+ BOOST_PROTO_AT(Z, N, DATA)
\
)
\
/**/
@@ -73,6 +84,36 @@
{
namespace detail
{
+ template<
+ typename Domain
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+ BOOST_PROTO_MAX_ARITY
+ , typename A
+ , = default_domain BOOST_PP_INTERCEPT
+ )
+ >
+ struct deduce_domain_
+ {
+ typedef Domain type;
+ };
+
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename A)>
+ struct deduce_domain_<
+ default_domain
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)
+ >
+ : deduce_domain_<
+ typename domain_of<A0>::type
+ , BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PROTO_MAX_ARITY,
typename A)
+ >
+ {};
+
+ template<>
+ struct deduce_domain_<default_domain>
+ {
+ typedef default_domain type;
+ };
+
template<typename Tag, typename Domain, typename Sequence,
std::size_t Size>
struct unpack_expr_
{};
@@ -128,7 +169,7 @@
{
template<typename Tag, typename Sequence, typename, typename>
struct unpack_expr
- : detail::unpack_expr_<Tag, default_domain, Sequence,
fusion::result_of::size<Sequence>::type::value>
+ : detail::unpack_expr_<Tag, deduce_domain, Sequence,
fusion::result_of::size<Sequence>::type::value>
{};
template<typename Tag, typename Domain, typename Sequence>
@@ -138,13 +179,25 @@
template<typename Tag
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A), typename,
typename>
struct make_expr
- : detail::make_expr_<Tag, default_domain
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A) >
+ : make_expr<Tag, deduce_domain
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A) >
{};
template<typename Tag, typename Domain
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A) >
struct make_expr<Tag, Domain
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A), typename
Domain::boost_proto_is_domain_>
: detail::make_expr_<Tag, Domain
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A) >
{};
+
+ template<typename Tag
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A) >
+ struct make_expr<Tag, deduce_domain
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A), void>
+ : detail::make_expr_<
+ Tag
+ , typename detail::deduce_domain_<
+ typename domain_of<A0>::type
+ , BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PROTO_MAX_ARITY, A)
+ >::type
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)
+ >
+ {};
}
namespace functional
@@ -156,6 +209,13 @@
struct result
{};
+ template<typename A>
+ typename result_of::make_expr<Tag, Domain, A>::type const
+ operator ()(A &a) const
+ {
+ return result_of::make_expr<Tag, Domain, A>::call(a);
+ }
+
#define BOOST_PP_ITERATION_PARAMS_1
\
(4, (1, BOOST_PROTO_MAX_ARITY,
<boost/xpressive/proto/make_expr.hpp>, 2)) \
/**/
@@ -176,15 +236,15 @@
{};
template<typename A>
- typename result_of::make_expr<tag::terminal, Domain, A
&>::type operator ()(A &a) const
+ typename result_of::make_expr<tag::terminal, Domain, A>::type
operator ()(A &a) const
{
- return result_of::make_expr<tag::terminal, Domain, A
&>::call(a);
+ return result_of::make_expr<tag::terminal, Domain,
A>::call(a);
}
template<typename A>
- typename result_of::make_expr<tag::terminal, Domain, A const
&>::type operator ()(A const &a) const
+ typename result_of::make_expr<tag::terminal, Domain, A
const>::type operator ()(A const &a) const
{
- return result_of::make_expr<tag::terminal, Domain, A const
&>::call(a);
+ return result_of::make_expr<tag::terminal, Domain, A
const>::call(a);
}
};
@@ -230,12 +290,8 @@
{};
}
- #define BOOST_PP_ITERATION_PARAMS_1
\
- (4, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/make_expr.hpp>,
3)) \
- /**/
-
- #include BOOST_PP_ITERATE()
-
+ /// unpack_expr
+ ///
template<typename Tag, typename Sequence>
typename lazy_disable_if<
is_domain<Sequence>
@@ -246,13 +302,17 @@
return result_of::unpack_expr<Tag, Sequence>::call(sequence);
}
- template<typename Tag, typename Domain, typename Sequence>
- typename result_of::unpack_expr<Tag, Domain, Sequence>::type const
- unpack_expr(Sequence const &sequence)
+ /// \overload
+ ///
+ template<typename Tag, typename Domain, typename Sequence2>
+ typename result_of::unpack_expr<Tag, Domain, Sequence2>::type const
+ unpack_expr(Sequence2 const &sequence2)
{
- return result_of::unpack_expr<Tag, Domain,
Sequence>::call(sequence);
+ return result_of::unpack_expr<Tag, Domain,
Sequence2>::call(sequence2);
}
+ /// make_expr
+ ///
template<typename Tag, typename A0>
typename lazy_disable_if<
is_domain<A0>
@@ -263,18 +323,28 @@
return result_of::make_expr<Tag, A0>::call(a0);
}
- template<typename Tag, typename Domain, typename A0>
- typename result_of::make_expr<Tag, Domain, A0>::type const
- make_expr(A0 &a0 BOOST_PROTO_DISABLE_IF_IS_CONST(A0))
+ /// \overload
+ ///
+ template<typename Tag, typename Domain, typename B0>
+ typename result_of::make_expr<Tag, Domain, B0>::type const
+ make_expr(B0 &b0 BOOST_PROTO_DISABLE_IF_IS_CONST(B0))
{
- return result_of::make_expr<Tag, Domain, A0>::call(a0);
+ return result_of::make_expr<Tag, Domain, B0>::call(b0);
}
+
+ #define BOOST_PP_ITERATION_PARAMS_1
\
+ (4, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/make_expr.hpp>,
3)) \
+ /**/
+
+ #include BOOST_PP_ITERATE()
}}
- #undef BOOST_PROTO_AS_ARG_TYPE
- #undef BOOST_PROTO_AS_ARG
- #undef BOOST_PROTO_AT_TYPE
#undef BOOST_PROTO_AT
+ #undef BOOST_PROTO_AT_TYPE
+ #undef BOOST_PROTO_AS_ARG
+ #undef BOOST_PROTO_AS_ARG_TYPE
+ #undef BOOST_PROTO_AS_ARG_AT
+ #undef BOOST_PROTO_AS_ARG_AT_TYPE
#endif // BOOST_PROTO_MAKE_EXPR_HPP_EAN_04_01_2005
@@ -306,7 +376,7 @@
{
typedef expr<
Tag
- , BOOST_PP_CAT(args, N)<BOOST_PP_ENUM(N, BOOST_PROTO_AT_TYPE,
(Sequence const, Domain)) >
+ , BOOST_PP_CAT(args, N)<BOOST_PP_ENUM(N,
BOOST_PROTO_AS_ARG_AT_TYPE, (Sequence const, Domain)) >
> expr_type;
typedef typename Domain::template apply<expr_type>::type type;
@@ -314,12 +384,28 @@
static type const call(Sequence const &sequence)
{
expr_type that = {
- BOOST_PP_ENUM(N, BOOST_PROTO_AT, (sequence, Domain))
+ BOOST_PP_ENUM(N, BOOST_PROTO_AS_ARG_AT, (sequence, Domain))
};
return Domain::make(that);
}
};
+ template<typename Tag, typename Sequence>
+ struct unpack_expr_<Tag, deduce_domain, Sequence, N>
+ : unpack_expr_<
+ Tag
+ , typename detail::deduce_domain_<
+ typename domain_of<
+ BOOST_PROTO_AT_TYPE(~, 0, (Sequence const, ~))
+ >::type
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(N))
+ BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_AT_TYPE, (Sequence
const, ~))
+ >::type
+ , Sequence
+ , N
+ >
+ {};
+
#undef N
#elif BOOST_PP_ITERATION_FLAGS() == 2
@@ -354,6 +440,8 @@
#define N BOOST_PP_ITERATION()
+ /// \overload
+ ///
template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
typename lazy_disable_if<
is_domain<A0>
@@ -366,12 +454,14 @@
);
}
- template<typename Tag, typename Domain
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
- typename result_of::make_expr<Tag, Domain
BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>::type const
- make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a))
+ /// \overload
+ ///
+ template<typename Tag, typename Domain
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename B)>
+ typename result_of::make_expr<Tag, Domain
BOOST_PP_ENUM_TRAILING_PARAMS(N, const B)>::type const
+ make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const B, &b))
{
- return result_of::make_expr<Tag, Domain
BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>::call(
- BOOST_PP_ENUM_PARAMS(N, a)
+ return result_of::make_expr<Tag, Domain
BOOST_PP_ENUM_TRAILING_PARAMS(N, const B)>::call(
+ BOOST_PP_ENUM_PARAMS(N, b)
);
}
Index: proto_fwd.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/proto_fwd.hpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- proto_fwd.hpp 26 May 2007 00:53:57 -0000 1.67
+++ proto_fwd.hpp 27 May 2007 03:56:20 -0000 1.68
@@ -206,6 +206,8 @@
typedef domain<> default_domain;
+ struct deduce_domain;
+
template<typename Expr, typename Derived, typename Domain =
default_domain, typename Tag = typename Expr::tag_type>
struct extends;
@@ -282,6 +284,9 @@
template<typename Expr>
struct tag_of;
+ template<typename T, typename EnableIf = void>
+ struct domain_of;
+
template<typename Expr>
struct id;
@@ -365,16 +370,16 @@
template<long N>
struct arg_c;
- template<typename Tag, typename Domain = default_domain>
+ template<typename Tag, typename Domain = deduce_domain>
struct make_expr;
- template<typename Tag, typename Domain = default_domain>
+ template<typename Tag, typename Domain = deduce_domain>
struct unpack_expr;
- template<typename Tag, typename Domain = default_domain>
+ template<typename Tag, typename Domain = deduce_domain>
struct unfused_expr_fun;
- template<typename Tag, typename Domain = default_domain>
+ template<typename Tag, typename Domain = deduce_domain>
struct unfused_expr;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs