|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50164 - in branches/release: . boost/proto libs/proto/doc libs/proto/doc/reference
From: eric_at_[hidden]
Date: 2008-12-06 15:59:41
Author: eric_niebler
Date: 2008-12-06 15:59:40 EST (Sat, 06 Dec 2008)
New Revision: 50164
URL: http://svn.boost.org/trac/boost/changeset/50164
Log:
Merged revisions 50106 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r50106 | eric_niebler | 2008-12-03 22:14:06 -0800 (Wed, 03 Dec 2008) | 1 line
unpack_expr works with Fusion Forward Sequences
........
Properties modified:
branches/release/ (props changed)
Text files modified:
branches/release/boost/proto/make_expr.hpp | 157 +++++++++++++++++++++++++++------------
branches/release/libs/proto/doc/proto.qbk | 2
branches/release/libs/proto/doc/reference/make_expr.xml | 24 +++--
3 files changed, 121 insertions(+), 62 deletions(-)
Modified: branches/release/boost/proto/make_expr.hpp
==============================================================================
--- branches/release/boost/proto/make_expr.hpp (original)
+++ branches/release/boost/proto/make_expr.hpp 2008-12-06 15:59:40 EST (Sat, 06 Dec 2008)
@@ -47,12 +47,14 @@
#include <boost/proto/domain.hpp>
#include <boost/proto/generate.hpp>
#if BOOST_VERSION >= 103500
- # include <boost/fusion/include/at.hpp>
- # include <boost/fusion/include/value_at.hpp>
+ # include <boost/fusion/include/begin.hpp>
+ # include <boost/fusion/include/next.hpp>
+ # include <boost/fusion/include/value_of.hpp>
# include <boost/fusion/include/size.hpp>
#else
- # include <boost/spirit/fusion/sequence/at.hpp>
- # include <boost/spirit/fusion/sequence/value_at.hpp>
+ # include <boost/spirit/fusion/sequence/begin.hpp>
+ # include <boost/spirit/fusion/iterator/next.hpp>
+ # include <boost/spirit/fusion/iterator/value_of.hpp>
# include <boost/spirit/fusion/sequence/size.hpp>
#endif
#include <boost/proto/detail/poly_function.hpp>
@@ -99,37 +101,67 @@
/// INTERNAL ONLY
///
- # define BOOST_PROTO_AT_TYPE(Z, N, DATA) \
+ #define BOOST_PROTO_FUSION_NEXT_ITERATOR_TYPE(Z, N, DATA) \
+ typedef typename fusion::BOOST_PROTO_FUSION_RESULT_OF::next< \
+ BOOST_PP_CAT(fusion_iterator, N)>::type \
+ BOOST_PP_CAT(fusion_iterator, BOOST_PP_INC(N)); \
+ /**/
+
+ /// INTERNAL ONLY
+ ///
+ #define BOOST_PROTO_FUSION_ITERATORS_TYPE(N) \
+ typedef \
+ typename fusion::BOOST_PROTO_FUSION_RESULT_OF::begin<Sequence const>::type \
+ fusion_iterator0; \
+ BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_PROTO_FUSION_NEXT_ITERATOR_TYPE, fusion_iterator) \
+ /**/
+
+ /// INTERNAL ONLY
+ ///
+ #define BOOST_PROTO_FUSION_AT_TYPE(Z, N, DATA) \
typename add_const< \
- typename fusion::BOOST_PROTO_FUSION_RESULT_OF::value_at_c< \
- BOOST_PP_TUPLE_ELEM(3, 0, DATA) \
- , N \
+ typename fusion::BOOST_PROTO_FUSION_RESULT_OF::value_of< \
+ BOOST_PP_CAT(fusion_iterator, N) \
>::type \
>::type \
/**/
/// INTERNAL ONLY
///
- # define BOOST_PROTO_AT(Z, N, DATA) \
- fusion::BOOST_PROTO_FUSION_AT_C(N, BOOST_PP_TUPLE_ELEM(3, 1, DATA)) \
+ #define BOOST_PROTO_FUSION_NEXT_ITERATOR(Z, N, DATA) \
+ BOOST_PP_CAT(fusion_iterator, BOOST_PP_INC(N)) BOOST_PP_CAT(it, BOOST_PP_INC(N)) = \
+ fusion::next(BOOST_PP_CAT(it, N)); \
/**/
/// INTERNAL ONLY
///
- #define BOOST_PROTO_AS_CHILD_AT_TYPE(Z, N, DATA) \
- typename boost::proto::detail::protoify_< \
- BOOST_PROTO_AT_TYPE(Z, N, DATA) \
- , BOOST_PP_TUPLE_ELEM(3, 2, DATA) \
+ #define BOOST_PROTO_FUSION_ITERATORS(N) \
+ fusion_iterator0 it0 = fusion::begin(sequence); \
+ BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_PROTO_FUSION_NEXT_ITERATOR, fusion_iterator) \
+ /**/
+
+ /// INTERNAL ONLY
+ ///
+ #define BOOST_PROTO_FUSION_AT(Z, N, DATA) \
+ *BOOST_PP_CAT(it, N) \
+ /**/
+
+ /// INTERNAL ONLY
+ ///
+ #define BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE(Z, N, DATA) \
+ typename detail::protoify_< \
+ BOOST_PROTO_FUSION_AT_TYPE(Z, N, DATA) \
+ , Domain \
>::type \
/**/
/// INTERNAL ONLY
///
- #define BOOST_PROTO_AS_CHILD_AT(Z, N, DATA) \
- boost::proto::detail::protoify_< \
- BOOST_PROTO_AT_TYPE(Z, N, DATA) \
- , BOOST_PP_TUPLE_ELEM(3, 2, DATA) \
- >::call(BOOST_PROTO_AT(Z, N, DATA)) \
+ #define BOOST_PROTO_FUSION_AS_CHILD_AT(Z, N, DATA) \
+ detail::protoify_< \
+ BOOST_PROTO_FUSION_AT_TYPE(Z, N, DATA) \
+ , Domain \
+ >::call(BOOST_PROTO_FUSION_AT(Z, N, DATA)) \
/**/
namespace detail
@@ -222,9 +254,8 @@
{
typedef
typename add_const<
- typename fusion::BOOST_PROTO_FUSION_RESULT_OF::value_at_c<
- Sequence
- , 0
+ typename fusion::BOOST_PROTO_FUSION_RESULT_OF::value_of<
+ typename fusion::BOOST_PROTO_FUSION_RESULT_OF::begin<Sequence>::type
>::type
>::type
terminal_type;
@@ -449,7 +480,7 @@
/// Use the <tt>result_of::unpack_expr\<\></tt> metafunction to
/// compute the return type of the \c unpack_expr() function.
///
- /// \c Sequence is a Fusion Random Access Sequence.
+ /// \c Sequence is a Fusion Forward Sequence.
///
/// In this specialization, the domain is deduced from the
/// domains of the child types. (If
@@ -463,10 +494,12 @@
>
struct unpack_expr
{
- /// Same as <tt>result_of::make_expr\<Tag,
- /// fusion::value_at\<Sequence, 0\>::::type, ...
- /// fusion::value_at\<Sequence, N-1\>::::type\>::::type</tt>,
- /// where \c N is the size of \c Sequence.
+ /// Let \c S be the type of a Fusion Random Access Sequence
+ /// equivalent to \c Sequence. Then \c type is the
+ /// same as <tt>result_of::make_expr\<Tag,
+ /// fusion::result_of::value_at_c\<S, 0\>::::type, ...
+ /// fusion::result_of::value_at_c\<S, N-1\>::::type\>::::type</tt>,
+ /// where \c N is the size of \c S.
typedef
typename detail::unpack_expr_<
Tag
@@ -485,10 +518,12 @@
template<typename Tag, typename Domain, typename Sequence>
struct unpack_expr<Tag, Domain, Sequence, typename Domain::proto_is_domain_>
{
- /// Same as <tt>result_of::make_expr\<Tag, Domain,
- /// fusion::value_at\<Sequence, 0\>::::type, ...
- /// fusion::value_at\<Sequence, N-1\>::::type\>::::type</tt>,
- /// where \c N is the size of \c Sequence.
+ /// Let \c S be the type of a Fusion Random Access Sequence
+ /// equivalent to \c Sequence. Then \c type is the
+ /// same as <tt>result_of::make_expr\<Tag, Domain,
+ /// fusion::result_of::value_at_c\<S, 0\>::::type, ...
+ /// fusion::result_of::value_at_c\<S, N-1\>::::type\>::::type</tt>,
+ /// where \c N is the size of \c S.
typedef
typename detail::unpack_expr_<
Tag
@@ -608,7 +643,7 @@
/// Construct an expression node with tag type \c Tag
/// and in the domain \c Domain.
///
- /// \param sequence A Fusion Random Access Sequence
+ /// \param sequence A Fusion Forward Sequence
/// \return <tt>proto::unpack_expr\<Tag, Domain\>(sequence)</tt>
template<typename Sequence>
typename result_of::unpack_expr<Tag, Domain, Sequence const>::type
@@ -734,7 +769,7 @@
/// \brief Construct an expression of the requested tag type
/// with a domain and with childres from the specified Fusion
- /// Random Access Sequence.
+ /// Forward Sequence.
///
/// This function template may be invoked either with or without
/// specifying a \c Domain argument. If no domain is specified,
@@ -743,9 +778,10 @@
/// \c default_domain, if any such domain exists, or
/// \c default_domain otherwise.
///
+ /// Let \c s be a Fusion Random Access Sequence equivalent to \c sequence.
/// Let <tt>wrap_\<N\>(s)</tt>, where \c s has type \c S, be defined
/// such that:
- /// \li If <tt>fusion::value_at\<S,N\>::::type</tt> is a reference,
+ /// \li If <tt>fusion::result_of::value_at_c\<S,N\>::::type</tt> is a reference,
/// <tt>wrap_\<N\>(s)</tt> is equivalent to
/// <tt>as_child\<Domain\>(fusion::at_c\<N\>(s))</tt>.
/// \li Otherwise, <tt>wrap_\<N\>(s)</tt> is equivalent to
@@ -755,8 +791,8 @@
/// <tt>expr\<Tag, listN\<B0,...BN\> \>::::make(b0,...bN)</tt>
/// where \c Bx is the type of \c bx.
///
- /// \param sequence a Fusion Random Access Sequence.
- /// \return <tt>Domain()(make_\<Tag\>(wrap_\<0\>(s),...wrap_\<N-1\>(S)))</tt>,
+ /// \param sequence a Fusion Forward Sequence.
+ /// \return <tt>Domain()(make_\<Tag\>(wrap_\<0\>(s),...wrap_\<N-1\>(s)))</tt>,
/// where N is the size of \c Sequence.
template<typename Tag, typename Sequence>
typename lazy_disable_if<
@@ -832,10 +868,14 @@
# pragma warning(pop)
#endif
- #undef BOOST_PROTO_AT
- #undef BOOST_PROTO_AT_TYPE
- #undef BOOST_PROTO_AS_CHILD_AT
- #undef BOOST_PROTO_AS_CHILD_AT_TYPE
+ #undef BOOST_PROTO_FUSION_AT
+ #undef BOOST_PROTO_FUSION_AT_TYPE
+ #undef BOOST_PROTO_FUSION_AS_CHILD_AT
+ #undef BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE
+ #undef BOOST_PROTO_FUSION_NEXT_ITERATOR
+ #undef BOOST_PROTO_FUSION_NEXT_ITERATOR_TYPE
+ #undef BOOST_PROTO_FUSION_ITERATORS
+ #undef BOOST_PROTO_FUSION_ITERATORS_TYPE
#endif // BOOST_PROTO_MAKE_EXPR_HPP_EAN_04_01_2005
@@ -962,10 +1002,12 @@
template<typename Tag, typename Domain, typename Sequence>
struct unpack_expr_<Tag, Domain, Sequence, N>
{
+ BOOST_PROTO_FUSION_ITERATORS_TYPE(N)
+
typedef proto::expr<
Tag
, BOOST_PP_CAT(list, N)<
- BOOST_PP_ENUM(N, BOOST_PROTO_AS_CHILD_AT_TYPE, (Sequence const, ~, Domain))
+ BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE, ~)
>
> expr_type;
@@ -973,8 +1015,9 @@
static type const call(Sequence const &sequence)
{
+ BOOST_PROTO_FUSION_ITERATORS(N)
expr_type that = {
- BOOST_PP_ENUM(N, BOOST_PROTO_AS_CHILD_AT, (Sequence const, sequence, Domain))
+ BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AS_CHILD_AT, ~)
};
return Domain()(that);
}
@@ -982,15 +1025,27 @@
template<typename Tag, typename Sequence>
struct unpack_expr_<Tag, deduce_domain, Sequence, N>
- : unpack_expr_<
- Tag
- , typename BOOST_PP_CAT(deduce_domain, N)<
- BOOST_PP_ENUM(N, BOOST_PROTO_AT_TYPE, (Sequence const, ~, ~))
- >::type
- , Sequence
- , N
- >
- {};
+ {
+ BOOST_PROTO_FUSION_ITERATORS_TYPE(N)
+
+ typedef
+ unpack_expr_<
+ Tag
+ , typename BOOST_PP_CAT(deduce_domain, N)<
+ BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AT_TYPE, ~)
+ >::type
+ , Sequence
+ , N
+ >
+ other;
+
+ typedef typename other::type type;
+
+ static type const call(Sequence const &sequence)
+ {
+ return other::call(sequence);
+ }
+ };
#undef N
#undef M
Modified: branches/release/libs/proto/doc/proto.qbk
==============================================================================
--- branches/release/libs/proto/doc/proto.qbk (original)
+++ branches/release/libs/proto/doc/proto.qbk 2008-12-06 15:59:40 EST (Sat, 06 Dec 2008)
@@ -51,6 +51,8 @@
[funcref boost::proto::deep_copy `proto::deep_copy()`]]
[def _domain_
[classref boost::proto::domain `proto::domain<>`]]
+[def _domain_
+ [classref boost::proto::default_domain `proto::default_domain`]]
[def _extends_
[classref boost::proto::extends `proto::extends<>`]]
[def _as_expr_
Modified: branches/release/libs/proto/doc/reference/make_expr.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/make_expr.xml (original)
+++ branches/release/libs/proto/doc/reference/make_expr.xml 2008-12-06 15:59:40 EST (Sat, 06 Dec 2008)
@@ -122,7 +122,7 @@
<parameter name="sequence">
<paramtype>Sequence const &</paramtype>
<description>
- <para>A Fusion Random Access Sequence </para>
+ <para>A Fusion Forward Sequence </para>
</description>
</parameter>
<description>
@@ -243,7 +243,7 @@
function.
</para>
<para>
- <computeroutput>Sequence</computeroutput> is a Fusion Random Access Sequence.
+ <computeroutput>Sequence</computeroutput> is a Fusion Forward Sequence.
</para>
<para>
In this specialization, the domain is deduced from the domains of the child types.
@@ -252,13 +252,13 @@
</para>
</description>
<typedef name="type">
- <purpose>Where N is the size of Sequence.</purpose>
+ <purpose>Where S is a RandomAccessSequence equivalent to Sequence, and N is the size of S.</purpose>
<type>
typename <classname>proto::result_of::make_expr</classname><
Tag,
- typename fusion::value_at<Sequence, 0>::type,
+ typename fusion::result_of::value_at_c<<replaceable>S</replaceable>, 0>::type,
...
- typename fusion::value_at<Sequence, <replaceable>N</replaceable>-1>::type
+ typename fusion::result_of::value_at_c<<replaceable>S</replaceable>, <replaceable>N</replaceable>-1>::type
>::type
</type>
</typedef>
@@ -286,14 +286,14 @@
</para>
</description>
<typedef name="type">
- <purpose>Where N is the size of Sequence.</purpose>
+ <purpose>Where S is a RandomAccessSequence equivalent to Sequence, and N is the size of S.</purpose>
<type>
typename <classname>proto::result_of::make_expr</classname><
Tag,
Domain,
- typename fusion::value_at<Sequence, 0>::type,
+ typename fusion::result_of::value_at_c<<replaceable>S</replaceable>, 0>::type,
...
- typename fusion::value_at<Sequence, <replaceable>N</replaceable>-1>::type
+ typename fusion::result_of::value_at_c<<replaceable>S</replaceable>, <replaceable>N</replaceable>-1>::type
>::type
</type>
</typedef>
@@ -379,7 +379,7 @@
<parameter name="sequence">
<paramtype>Sequence const &</paramtype>
<description>
- <para>A Fusion Random Access Sequence.</para>
+ <para>A Fusion Forward Sequence.</para>
</description>
</parameter>
</signature>
@@ -395,7 +395,7 @@
</parameter>
</signature>
<purpose>Construct an expression of the requested tag type with a domain and with children
- from the specified Fusion Random Access Sequence.</purpose>
+ from the specified Fusion Forward Sequence.</purpose>
<description>
<para>
This function template may be invoked either with or without specifying a
@@ -406,12 +406,14 @@
exists, or <computeroutput><classname>proto::default_domain</classname></computeroutput> otherwise.
</para>
<para>
+ Let <computeroutput>s</computeroutput> be a Fusion Random Access Sequence equivalent to
+ <computeroutput>sequence</computeroutput>.
Let <computeroutput><replaceable>WRAP</replaceable><N>(s)</computeroutput>, where
<computeroutput>s</computeroutput> has type <computeroutput>S</computeroutput>, be defined such that:
<itemizedlist>
<listitem>
<para>
- If <computeroutput>fusion::value_at<S,N>::type</computeroutput> is a reference,
+ If <computeroutput>fusion::result_of::value_at_c<S,N>::type</computeroutput> is a reference,
<computeroutput><replaceable>WRAP</replaceable><N>(s)</computeroutput> is equivalent to
<computeroutput><functionname>proto::as_child</functionname><Domain>(fusion::at_c<N>(s))</computeroutput>.
</para>
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