Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62781 - in trunk/boost/proto: . detail
From: eric_at_[hidden]
Date: 2010-06-10 21:34:44


Author: eric_niebler
Date: 2010-06-10 21:34:42 EDT (Thu, 10 Jun 2010)
New Revision: 62781
URL: http://svn.boost.org/trac/boost/changeset/62781

Log:
remove requirement that Generators have proto_base_generator typedef
Text files modified:
   trunk/boost/proto/detail/as_expr.hpp | 53 ++++++++++++++++++++++++---------------
   trunk/boost/proto/domain.hpp | 16 +++++++++--
   trunk/boost/proto/generate.hpp | 10 -------
   trunk/boost/proto/proto_fwd.hpp | 4 ++
   trunk/boost/proto/traits.hpp | 19 ++++++++++++++
   5 files changed, 68 insertions(+), 34 deletions(-)

Modified: trunk/boost/proto/detail/as_expr.hpp
==============================================================================
--- trunk/boost/proto/detail/as_expr.hpp (original)
+++ trunk/boost/proto/detail/as_expr.hpp 2010-06-10 21:34:42 EDT (Thu, 10 Jun 2010)
@@ -36,6 +36,19 @@
     struct as_child;
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Generator>
+ struct base_generator
+ {
+ typedef Generator type;
+ };
+
+ template<typename Generator>
+ struct base_generator<use_basic_expr<Generator> >
+ {
+ typedef Generator type;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename Expr, typename Generator, bool SameGenerator>
     struct already_expr
     {
@@ -120,8 +133,8 @@
             T
           , Generator
           , is_same<
- typename Generator::proto_base_generator
- , typename T::proto_generator::proto_base_generator
+ Generator
+ , typename base_generator<typename T::proto_generator>::type
>::value
>
     {};
@@ -133,15 +146,15 @@
             T
           , Generator
           , is_same<
- typename Generator::proto_base_generator
- , typename T::proto_generator::proto_base_generator
+ Generator
+ , typename base_generator<typename T::proto_generator>::type
>::value
>
     {};
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename T>
- struct as_expr<T, proto::_, false, false>
+ struct as_expr<T, proto::default_generator, false, false>
     {
         typedef typename term_traits<T &>::value_type value_type;
         typedef proto::expr<proto::tag::terminal, term<value_type>, 0> result_type;
@@ -154,7 +167,7 @@
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename T>
- struct as_expr<T, proto::_, false, true>
+ struct as_expr<T, proto::default_generator, false, true>
     {
         typedef typename term_traits<T &>::value_type value_type;
         typedef proto::basic_expr<proto::tag::terminal, term<value_type>, 0> result_type;
@@ -167,14 +180,14 @@
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename T>
- struct as_expr<T, proto::_, true, false>
- : already_expr<T, proto::_, true>
+ struct as_expr<T, proto::default_generator, true, false>
+ : already_expr<T, proto::default_generator, true>
     {};
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename T>
- struct as_expr<T, proto::_, true, true>
- : already_expr<T, proto::_, true>
+ struct as_expr<T, proto::default_generator, true, true>
+ : already_expr<T, proto::default_generator, true>
     {};
 
 
@@ -211,8 +224,8 @@
             T
           , Generator
           , is_same<
- typename Generator::proto_base_generator
- , typename T::proto_generator::proto_base_generator
+ Generator
+ , typename base_generator<typename T::proto_generator>::type
>::value
>
     {};
@@ -224,15 +237,15 @@
             T
           , Generator
           , is_same<
- typename Generator::proto_base_generator
- , typename T::proto_generator::proto_base_generator
+ Generator
+ , typename base_generator<typename T::proto_generator>::type
>::value
>
     {};
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename T>
- struct as_child<T, proto::_, false, false>
+ struct as_child<T, proto::default_generator, false, false>
     {
         typedef proto::expr<proto::tag::terminal, term<T &>, 0> result_type;
 
@@ -244,7 +257,7 @@
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename T>
- struct as_child<T, proto::_, false, true>
+ struct as_child<T, proto::default_generator, false, true>
     {
         typedef proto::basic_expr<proto::tag::terminal, term<T &>, 0> result_type;
 
@@ -256,14 +269,14 @@
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename T>
- struct as_child<T, proto::_, true, false>
- : already_child<T, proto::_, true>
+ struct as_child<T, proto::default_generator, true, false>
+ : already_child<T, proto::default_generator, true>
     {};
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     template<typename T>
- struct as_child<T, proto::_, true, true>
- : already_child<T, proto::_, true>
+ struct as_child<T, proto::default_generator, true, true>
+ : already_child<T, proto::default_generator, true>
     {};
 
 }}}

Modified: trunk/boost/proto/domain.hpp
==============================================================================
--- trunk/boost/proto/domain.hpp (original)
+++ trunk/boost/proto/domain.hpp 2010-06-10 21:34:42 EDT (Thu, 10 Jun 2010)
@@ -83,7 +83,7 @@
     template<
         typename Generator // = default_generator
       , typename Grammar // = proto::_
- , typename Super // = detail::not_a_domain
+ , typename Super // = no_super_domain
>
     struct domain
       : Generator
@@ -122,7 +122,12 @@
         ///
         template<typename T, typename Callable = proto::callable>
         struct as_expr
- : detail::as_expr<T, Generator>
+ : detail::as_expr<
+ T
+ , typename detail::base_generator<Generator>::type
+ , is_expr<T>::value
+ , wants_basic_expr<Generator>::value
+ >
         {
             BOOST_PROTO_CALLABLE()
         };
@@ -147,7 +152,12 @@
         ///
         template<typename T, typename Callable = proto::callable>
         struct as_child
- : detail::as_child<T, Generator>
+ : detail::as_child<
+ T
+ , typename detail::base_generator<Generator>::type
+ , is_expr<T>::value
+ , wants_basic_expr<Generator>::value
+ >
         {
             BOOST_PROTO_CALLABLE()
         };

Modified: trunk/boost/proto/generate.hpp
==============================================================================
--- trunk/boost/proto/generate.hpp (original)
+++ trunk/boost/proto/generate.hpp 2010-06-10 21:34:42 EDT (Thu, 10 Jun 2010)
@@ -88,8 +88,6 @@
         {
             BOOST_PROTO_CALLABLE()
 
- typedef default_generator proto_base_generator;
-
             template<typename Sig>
             struct result;
 
@@ -127,8 +125,6 @@
             BOOST_PROTO_CALLABLE()
             BOOST_PROTO_USE_BASIC_EXPR()
 
- typedef generator proto_base_generator;
-
             template<typename Sig>
             struct result;
 
@@ -175,8 +171,6 @@
             BOOST_PROTO_CALLABLE()
             BOOST_PROTO_USE_BASIC_EXPR()
 
- typedef pod_generator proto_base_generator;
-
             template<typename Sig>
             struct result;
 
@@ -224,8 +218,6 @@
         {
             BOOST_PROTO_CALLABLE()
 
- typedef by_value_generator proto_base_generator;
-
             template<typename Sig>
             struct result;
 
@@ -277,8 +269,6 @@
         {
             BOOST_PROTO_CALLABLE()
 
- typedef compose_generators proto_base_generator;
-
             template<typename Sig>
             struct result;
 

Modified: trunk/boost/proto/proto_fwd.hpp
==============================================================================
--- trunk/boost/proto/proto_fwd.hpp (original)
+++ trunk/boost/proto/proto_fwd.hpp 2010-06-10 21:34:42 EDT (Thu, 10 Jun 2010)
@@ -258,10 +258,12 @@
     struct use_basic_expr;
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
+ typedef detail::not_a_domain no_super_domain;
+
     template<
         typename Generator = default_generator
       , typename Grammar = proto::_
- , typename Super = detail::not_a_domain
+ , typename Super = no_super_domain
>
     struct domain;
 

Modified: trunk/boost/proto/traits.hpp
==============================================================================
--- trunk/boost/proto/traits.hpp (original)
+++ trunk/boost/proto/traits.hpp 2010-06-10 21:34:42 EDT (Thu, 10 Jun 2010)
@@ -22,6 +22,7 @@
     #include <boost/preprocessor/repetition/repeat_from_to.hpp>
     #include <boost/preprocessor/facilities/intercept.hpp>
     #include <boost/preprocessor/arithmetic/sub.hpp>
+ #include <boost/static_assert.hpp>
     #include <boost/mpl/bool.hpp>
     #include <boost/mpl/aux_/template_arity.hpp>
     #include <boost/mpl/aux_/lambda_arity_param.hpp>
@@ -255,6 +256,9 @@
             template<typename Expr>
             struct value
             {
+ /// Verify that we are actually operating on a terminal
+ BOOST_STATIC_ASSERT(0 == Expr::proto_arity_c);
+
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::proto_child0 value_type;
@@ -274,6 +278,9 @@
             template<typename Expr>
             struct value<Expr &>
             {
+ /// Verify that we are actually operating on a terminal
+ BOOST_STATIC_ASSERT(0 == Expr::proto_arity_c);
+
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::proto_child0 value_type;
@@ -293,6 +300,9 @@
             template<typename Expr>
             struct value<Expr const &>
             {
+ /// Verify that we are actually operating on a terminal
+ BOOST_STATIC_ASSERT(0 == Expr::proto_arity_c);
+
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::proto_child0 value_type;
@@ -1301,6 +1311,9 @@
             template<typename Expr>
             struct child_c<Expr, N>
             {
+ /// Verify that we are not operating on a terminal
+ BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
+
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
@@ -1316,6 +1329,9 @@
             template<typename Expr>
             struct child_c<Expr &, N>
             {
+ /// Verify that we are not operating on a terminal
+ BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
+
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
@@ -1338,6 +1354,9 @@
             template<typename Expr>
             struct child_c<Expr const &, N>
             {
+ /// Verify that we are not operating on a terminal
+ BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
+
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_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