Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-04-17 17:30:31


Author: eric_niebler
Date: 2008-04-17 17:30:30 EDT (Thu, 17 Apr 2008)
New Revision: 44521
URL: http://svn.boost.org/trac/boost/changeset/44521

Log:
give metafunctions result<> and operator() like a transform
Text files modified:
   branches/proto/v4/boost/proto/proto_fwd.hpp | 8 +++
   branches/proto/v4/boost/proto/traits.hpp | 92 ++++++++++++++++++++--------------------
   branches/proto/v4/boost/proto/transform/impl.hpp | 18 ++++++-
   3 files changed, 68 insertions(+), 50 deletions(-)

Modified: branches/proto/v4/boost/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v4/boost/proto/proto_fwd.hpp (original)
+++ branches/proto/v4/boost/proto/proto_fwd.hpp 2008-04-17 17:30:30 EDT (Thu, 17 Apr 2008)
@@ -696,12 +696,20 @@
     struct is_transform;
 
     #define BOOST_PROTO_CALLABLE() typedef void proto_is_callable_;
+ #define BOOST_PROTO_TRANSFORM() typedef void proto_is_transform_;
 
     struct callable
     {
         BOOST_PROTO_CALLABLE()
     };
 
+ struct empty_base;
+
+ struct transform_base;
+
+ template<typename PrimitiveTransform, typename Base = transform_base>
+ struct transform;
+
     template<typename Grammar, typename Fun = Grammar>
     struct when;
 

Modified: branches/proto/v4/boost/proto/traits.hpp
==============================================================================
--- branches/proto/v4/boost/proto/traits.hpp (original)
+++ branches/proto/v4/boost/proto/traits.hpp 2008-04-17 17:30:30 EDT (Thu, 17 Apr 2008)
@@ -459,7 +459,7 @@
             /// a grammar element for matching terminal expressions, and a
             /// PrimitiveTransform that returns the current expression unchanged.
             template<typename T>
- struct terminal
+ struct terminal : transform<terminal<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::terminal, term<T> > type;
                 typedef type proto_base_expr;
@@ -494,7 +494,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U, typename V>
- struct if_else_
+ struct if_else_ : transform<if_else_<T, U, V>, empty_base>
             {
                 typedef proto::expr<proto::tag::if_else_, list3<T, U, V> > type;
                 typedef type proto_base_expr;
@@ -523,7 +523,7 @@
             /// Use <tt>unary_expr\<_, _\></tt> as a grammar element to match any
             /// unary expression.
             template<typename Tag, typename T>
- struct unary_expr
+ struct unary_expr : transform<unary_expr<Tag, T>, empty_base>
             {
                 typedef proto::expr<Tag, list1<T> > type;
                 typedef type proto_base_expr;
@@ -548,7 +548,7 @@
             /// Use <tt>binary_expr\<_, _, _\></tt> as a grammar element to match any
             /// binary expression.
             template<typename Tag, typename T, typename U>
- struct binary_expr
+ struct binary_expr : transform<binary_expr<Tag, T, U>, empty_base>
             {
                 typedef proto::expr<Tag, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -571,7 +571,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct unary_plus
+ struct unary_plus : transform<unary_plus<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::unary_plus, list1<T> > type;
                 typedef type proto_base_expr;
@@ -592,7 +592,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct negate
+ struct negate : transform<negate<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::negate, list1<T> > type;
                 typedef type proto_base_expr;
@@ -613,7 +613,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct dereference
+ struct dereference : transform<dereference<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::dereference, list1<T> > type;
                 typedef type proto_base_expr;
@@ -634,7 +634,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct complement
+ struct complement : transform<complement<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::complement, list1<T> > type;
                 typedef type proto_base_expr;
@@ -655,7 +655,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct address_of
+ struct address_of : transform<address_of<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::address_of, list1<T> > type;
                 typedef type proto_base_expr;
@@ -676,7 +676,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct logical_not
+ struct logical_not : transform<logical_not<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::logical_not, list1<T> > type;
                 typedef type proto_base_expr;
@@ -697,7 +697,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct pre_inc
+ struct pre_inc : transform<pre_inc<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::pre_inc, list1<T> > type;
                 typedef type proto_base_expr;
@@ -718,7 +718,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct pre_dec
+ struct pre_dec : transform<pre_dec<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::pre_dec, list1<T> > type;
                 typedef type proto_base_expr;
@@ -739,7 +739,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct post_inc
+ struct post_inc : transform<post_inc<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::post_inc, list1<T> > type;
                 typedef type proto_base_expr;
@@ -760,7 +760,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T>
- struct post_dec
+ struct post_dec : transform<post_dec<T>, empty_base>
             {
                 typedef proto::expr<proto::tag::post_dec, list1<T> > type;
                 typedef type proto_base_expr;
@@ -781,7 +781,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct shift_left
+ struct shift_left : transform<shift_left<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::shift_left, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -804,7 +804,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct shift_right
+ struct shift_right : transform<shift_right<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::shift_right, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -827,7 +827,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct multiplies
+ struct multiplies : transform<multiplies<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::multiplies, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -850,7 +850,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct divides
+ struct divides : transform<divides<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::divides, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -873,7 +873,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct modulus
+ struct modulus : transform<modulus<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::modulus, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -896,7 +896,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct plus
+ struct plus : transform<plus<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::plus, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -919,7 +919,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct minus
+ struct minus : transform<minus<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::minus, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -942,7 +942,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct less
+ struct less : transform<less<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::less, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -965,7 +965,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct greater
+ struct greater : transform<greater<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::greater, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -988,7 +988,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct less_equal
+ struct less_equal : transform<less_equal<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::less_equal, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1011,7 +1011,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct greater_equal
+ struct greater_equal : transform<greater_equal<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::greater_equal, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1034,7 +1034,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct equal_to
+ struct equal_to : transform<equal_to<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::equal_to, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1057,7 +1057,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct not_equal_to
+ struct not_equal_to : transform<not_equal_to<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::not_equal_to, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1080,7 +1080,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct logical_or
+ struct logical_or : transform<logical_or<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::logical_or, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1103,7 +1103,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct logical_and
+ struct logical_and : transform<logical_and<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::logical_and, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1126,7 +1126,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct bitwise_and
+ struct bitwise_and : transform<bitwise_and<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::bitwise_and, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1149,7 +1149,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct bitwise_or
+ struct bitwise_or : transform<bitwise_or<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::bitwise_or, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1172,7 +1172,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct bitwise_xor
+ struct bitwise_xor : transform<bitwise_xor<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::bitwise_xor, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1195,7 +1195,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct comma
+ struct comma : transform<comma<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::comma, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1214,7 +1214,7 @@
             };
 
             template<typename T, typename U>
- struct mem_ptr
+ struct mem_ptr : transform<mem_ptr<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::mem_ptr, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1237,7 +1237,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct assign
+ struct assign : transform<assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1260,7 +1260,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct shift_left_assign
+ struct shift_left_assign : transform<shift_left_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::shift_left_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1283,7 +1283,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct shift_right_assign
+ struct shift_right_assign : transform<shift_right_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::shift_right_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1306,7 +1306,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct multiplies_assign
+ struct multiplies_assign : transform<multiplies_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::multiplies_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1329,7 +1329,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct divides_assign
+ struct divides_assign : transform<divides_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::divides_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1352,7 +1352,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct modulus_assign
+ struct modulus_assign : transform<modulus_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::modulus_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1375,7 +1375,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct plus_assign
+ struct plus_assign : transform<plus_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::plus_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1398,7 +1398,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct minus_assign
+ struct minus_assign : transform<minus_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::minus_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1421,7 +1421,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct bitwise_and_assign
+ struct bitwise_and_assign : transform<bitwise_and_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::bitwise_and_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1444,7 +1444,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct bitwise_or_assign
+ struct bitwise_or_assign : transform<bitwise_or_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::bitwise_or_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1467,7 +1467,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct bitwise_xor_assign
+ struct bitwise_xor_assign : transform<bitwise_xor_assign<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::bitwise_xor_assign, list2<T, U> > type;
                 typedef type proto_base_expr;
@@ -1490,7 +1490,7 @@
             /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
             /// transform.
             template<typename T, typename U>
- struct subscript
+ struct subscript : transform<subscript<T, U>, empty_base>
             {
                 typedef proto::expr<proto::tag::subscript, list2<T, U> > type;
                 typedef type proto_base_expr;

Modified: branches/proto/v4/boost/proto/transform/impl.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/impl.hpp (original)
+++ branches/proto/v4/boost/proto/transform/impl.hpp 2008-04-17 17:30:30 EDT (Thu, 17 Apr 2008)
@@ -20,12 +20,22 @@
       : PrimitiveTransform::template impl<Expr, State, Data>
     {};
 
- template<typename PrimitiveTransform>
- struct transform
+ struct transform_base
     {
- typedef PrimitiveTransform transform_type;
- typedef void proto_is_transform_;
         BOOST_PROTO_CALLABLE()
+ BOOST_PROTO_TRANSFORM()
+ };
+
+ struct empty_base
+ {};
+
+ template<
+ typename PrimitiveTransform
+ , typename Base BOOST_PROTO_WHEN_BUILDING_DOCS(= transform_base)
+ >
+ struct transform : Base
+ {
+ typedef PrimitiveTransform transform_type;
 
         template<typename Sig>
         struct result;


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