Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-12-04 14:23:10


Author: eric_niebler
Date: 2007-12-04 14:23:09 EST (Tue, 04 Dec 2007)
New Revision: 41695
URL: http://svn.boost.org/trac/boost/changeset/41695

Log:
more clean-up
Text files modified:
   branches/proto/v3/boost/xpressive/proto/args.hpp | 28 ++++++++++------
   branches/proto/v3/boost/xpressive/proto/expr.hpp | 2
   branches/proto/v3/boost/xpressive/proto/transform/make.hpp | 63 +++++++++++++++++++++++++++------------
   3 files changed, 61 insertions(+), 32 deletions(-)

Modified: branches/proto/v3/boost/xpressive/proto/args.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/args.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/args.hpp 2007-12-04 14:23:09 EST (Tue, 04 Dec 2007)
@@ -71,6 +71,13 @@
             typedef cons<Tail...> cdr_type;
             car_type car;
             cdr_type cdr;
+
+ template<typename Head2, typename... Tail2>
+ static cons<Head, Tail...> make(Head2 &&head, Tail2 &&... tail)
+ {
+ cons<Head, Tail...> that = {head, cdr_type::make(tail...)};
+ return that;
+ }
         };
 
         template<>
@@ -89,6 +96,13 @@
             typedef cons<> cdr_type;
             car_type car;
             static cdr_type const cdr;
+
+ template<typename Head2>
+ static cons<Head> make(Head2 &&head)
+ {
+ cons<Head> that = {head};
+ return that;
+ }
         };
 
         template<typename Head>
@@ -105,18 +119,10 @@
                 typedef cons<UNCV(Args)...> type;
             };
 
- template<typename Head, typename... Tail>
- cons<UNCV(Head), UNCV(Tail)...> operator()(Head &&head, Tail &&... tail) const
- {
- cons<UNCV(Head), UNCV(Tail)...> that = {head, (*this)(std::forward<Tail>(tail)...)};
- return that;
- }
-
- template<typename Head>
- cons<UNCV(Head)> operator()(Head &&head) const
+ template<typename... Args>
+ cons<UNCV(Args)...> operator()(Args &&... args) const
             {
- cons<UNCV(Head)> that = {head};
- return that;
+ return cons<UNCV(Args)...>::make(args...);
             }
         };
 

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-04 14:23:09 EST (Tue, 04 Dec 2007)
@@ -73,7 +73,7 @@
             template<typename... A>
             static expr make(A &&... a)
             {
- expr that = {{a...}};
+ expr that = {Args::cons_type::make(a...)};
                 return that;
             }
 

Modified: branches/proto/v3/boost/xpressive/proto/transform/make.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/make.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/make.hpp 2007-12-04 14:23:09 EST (Tue, 04 Dec 2007)
@@ -12,7 +12,6 @@
 #include <boost/mpl/eval_if.hpp>
 #include <boost/mpl/aux_/has_type.hpp>
 #include <boost/utility/result_of.hpp>
-#include <boost/utility/enable_if.hpp>
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/args.hpp>
@@ -102,25 +101,52 @@
                 typedef void not_applied_;
             };
 
- template<typename Type, typename... Args>
- typename enable_if<is_aggregate<Type>, Type>::type
- construct_(Args &&... args)
+ template<typename Type, bool IsAggregate = is_aggregate<Type>::value>
+ struct construct_
             {
- Type that = { args... };
- return that;
- }
+ typedef Type result_type;
 
- template<typename Type, typename... Args>
- typename disable_if<is_aggregate<Type>, Type>::type
- construct_(Args &&... args)
- {
- return Type(args...);
- }
+ template<typename... Args>
+ Type operator()(Args &&... args) const
+ {
+ return Type(args...);
+ }
+ };
 
             template<typename Type>
- Type construct_()
+ struct construct_<Type, true>
+ {
+ typedef Type result_type;
+
+ template<typename... Args>
+ Type operator()(Args &&... args) const
+ {
+ Type that = {args...};
+ return that;
+ }
+
+ Type operator()() const
+ {
+ return Type();
+ }
+ };
+
+ template<typename T, typename A, long N>
+ struct construct_<expr<T, A, N>, true>
+ {
+ typedef expr<T, A, N> result_type;
+
+ template<typename... Args>
+ result_type operator()(Args &&... args) const
+ {
+ return result_type::make(args...);
+ }
+ };
+
+ template<typename Type, typename... Args>
+ Type construct(Args &&... args)
             {
- return Type();
+ return construct_<Type>()(args...);
             }
         }
 
@@ -140,7 +166,7 @@
             operator()(Expr const &expr, State const &state, Visitor &visitor) const
             {
                 typedef typename result<make(Expr, State, Visitor)>::type result_type;
- return detail::construct_<result_type>(when<_, Args>()(expr, state, visitor)...);
+ return detail::construct<result_type>(when<_, Args>()(expr, state, visitor)...);
             }
         };
 
@@ -157,10 +183,7 @@
             template<typename Expr, typename State, typename Visitor>
             expr<T, A, N> operator()(Expr const &expr, State const &state, Visitor &visitor) const
             {
- proto::expr<T, A, N> that = {{
- when<_, Args>()(expr, state, visitor)...
- }};
- return that;
+ return proto::expr<T, A, N>::make(when<_, Args>()(expr, state, visitor)...);
             }
         };
 


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