Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-12-04 13:28:03


Author: eric_niebler
Date: 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
New Revision: 41691
URL: http://svn.boost.org/trac/boost/changeset/41691

Log:
clean-up
Added:
   branches/proto/v3/boost/xpressive/proto/detail/indices.hpp (contents, props changed)
Text files modified:
   branches/proto/v3/boost/xpressive/proto/context/callable.hpp | 14 ++++-
   branches/proto/v3/boost/xpressive/proto/context/default.hpp | 5 +
   branches/proto/v3/boost/xpressive/proto/matches.hpp | 5 ++
   branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp | 16 ++++--
   branches/proto/v3/boost/xpressive/proto/traits.hpp | 98 ++++++++++++++++++++-------------------
   branches/proto/v3/boost/xpressive/proto/transform/fold_tree.hpp | 2
   branches/proto/v3/boost/xpressive/proto/transform/make.hpp | 2
   branches/proto/v3/libs/xpressive/proto/example/hello.cpp | 2
   8 files changed, 81 insertions(+), 63 deletions(-)

Modified: branches/proto/v3/boost/xpressive/proto/context/callable.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/context/callable.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/context/callable.hpp 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
@@ -20,6 +20,7 @@
 #include <boost/type_traits.hpp>
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/traits.hpp> // for arg_c
+#include <boost/xpressive/proto/detail/indices.hpp>
 #include <boost/xpressive/proto/detail/dont_care.hpp>
 
 namespace boost { namespace proto
@@ -72,7 +73,7 @@
         struct is_expr_handled_aux_;
 
         template<typename Expr, typename Context, typename... Args, int... Indices>
- struct is_expr_handled_aux_<Expr, Context, args<Args...>, op::detail::indices<Indices...> >
+ struct is_expr_handled_aux_<Expr, Context, args<Args...>, proto::detail::indices<Indices...> >
         {
             typedef typename make_dont_care<sizeof...(Args)>::type DontCare;
 
@@ -96,12 +97,17 @@
 
         template<typename Expr, typename Context, typename... Args>
         struct is_expr_handled<Expr, Context, args<Args...> >
- : is_expr_handled_aux_<Expr, Context, args<Args...>, typename op::detail::make_indices<sizeof...(Args)>::type >
+ : is_expr_handled_aux_<
+ Expr
+ , Context
+ , args<Args...>
+ , typename proto::detail::make_indices<sizeof...(Args)>::type
+ >
         {};
 
         template<typename Expr, typename Context, typename T>
         struct is_expr_handled<Expr, Context, term<T> >
- : is_expr_handled_aux_<Expr, Context, args<T>, op::detail::indices<0> >
+ : is_expr_handled_aux_<Expr, Context, args<T>, proto::detail::indices<0> >
         {};
 
     }
@@ -132,7 +138,7 @@
         };
 
         template<typename Expr, typename Context, int... Indices>
- struct callable_eval<Expr, Context, op::detail::indices<Indices...> >
+ struct callable_eval<Expr, Context, proto::detail::indices<Indices...> >
         {
             typedef
                 typename boost::result_of<

Modified: branches/proto/v3/boost/xpressive/proto/context/default.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/context/default.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/context/default.hpp 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
@@ -21,6 +21,7 @@
 #include <boost/xpressive/proto/tags.hpp>
 #include <boost/xpressive/proto/eval.hpp>
 #include <boost/xpressive/proto/traits.hpp> // for proto::arg_c()
+#include <boost/xpressive/proto/detail/indices.hpp>
 
 // If we're generating doxygen documentation, hide all the nasty
 // Boost.Typeof gunk.
@@ -127,7 +128,7 @@
         struct default_eval_function_;
 
         template<typename Expr, typename Context, int Zero, int... Indices>
- struct default_eval_function_<Expr, Context, op::detail::indices<Zero, Indices...> >
+ struct default_eval_function_<Expr, Context, proto::detail::indices<Zero, Indices...> >
         {
             typedef
                 typename proto::detail::result_of_fixup<
@@ -346,7 +347,7 @@
           : proto::detail::default_eval_function_<
                 Expr
               , Context
- , typename op::detail::make_indices<Expr::proto_arity>::type
+ , typename proto::detail::make_indices<Expr::proto_arity>::type
>
         {};
 

Added: branches/proto/v3/boost/xpressive/proto/detail/indices.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/indices.hpp 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
@@ -0,0 +1,50 @@
+///////////////////////////////////////////////////////////////////////////////
+/// \file indices.hpp
+/// Definintion of indices<>, a template for generating an
+/// argument pack of integers 1,2,3...
+//
+// Copyright 2007 Eric Niebler. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_PROTO_DETAIL_INDICES_HPP_EAN_12_04_2007
+#define BOOST_PROTO_DETAIL_INDICES_HPP_EAN_12_04_2007
+
+namespace boost { namespace proto { namespace detail
+{
+ template<int... I>
+ struct indices
+ {};
+
+ template<int N, int... I>
+ struct make_indices<N, indices<I...> >
+ : make_indices<N-4, indices<N-4, N-3, N-2, N-1, I...> >
+ {};
+
+ template<int... I>
+ struct make_indices<3, indices<I...> >
+ {
+ typedef indices<0, 1, 2, I...> type;
+ };
+
+ template<int... I>
+ struct make_indices<2, indices<I...> >
+ {
+ typedef indices<0, 1, I...> type;
+ };
+
+ template<int... I>
+ struct make_indices<1, indices<I...> >
+ {
+ typedef indices<0, I...> type;
+ };
+
+ template<int... I>
+ struct make_indices<0, indices<I...> >
+ {
+ typedef indices<I...> type;
+ };
+
+}}}
+
+#endif

Modified: branches/proto/v3/boost/xpressive/proto/matches.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/matches.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/matches.hpp 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
@@ -372,6 +372,11 @@
>::type
             {};
 
+ template<typename Expr, typename If>
+ struct matches_<Expr, proto::if_<If> >
+ : boost::result_of<when<_, If>(Expr, mpl::void_, mpl::void_)>::type
+ {};
+
             // handle proto::not_
             template<typename Expr, typename Grammar>
             struct matches_<Expr, proto::not_<Grammar> >

Modified: branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
@@ -17,6 +17,15 @@
 
 namespace boost { namespace proto
 {
+ namespace detail
+ {
+ template<int... I>
+ struct indices;
+
+ template<int N, typename T = indices<> >
+ struct make_indices;
+ }
+
     namespace wildns_
     {
         struct _;
@@ -223,11 +232,6 @@
         // BUGBUG move this elsewhere
         namespace detail
         {
- template<int... I>
- struct indices;
-
- template<int N, typename T = indices<> >
- struct make_indices;
         }
 
         template<typename T> struct terminal;
@@ -439,7 +443,7 @@
         struct callable_context;
 
         template<typename Expr, typename Context,
- typename Indices = typename op::detail::make_indices<
+ typename Indices = typename proto::detail::make_indices<
                 Expr::proto_arity == 0 ? 1 : Expr::proto_arity
>::type
>

Modified: branches/proto/v3/boost/xpressive/proto/traits.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/traits.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/traits.hpp 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
@@ -37,74 +37,78 @@
 
         namespace detail
         {
+ using argsns_::cons;
 
- template<typename Args, int N, typename Result = args<>, bool Done = (N == 0) >
- struct resize;
-
- template<typename Head, typename... Tail, int N, typename... Result>
- struct resize<args<Head, Tail...>, N, args<Result...>, false>
- : resize<args<Tail...>, N-1, args<Result..., Head> >
- {};
+ template<typename G, typename E, typename S, typename V>
+ struct apply_args;
 
- template<typename... Args, typename... Result>
- struct resize<args<Args...>, 0, args<Result...>, true>
+ template<typename G, typename E, typename S, typename V>
+ struct apply_args<args<G>, args<E>, S, V>
             {
- typedef args<Result...> type;
- };
-
- template<int... I>
- struct indices
- {};
-
- template<int N, int... I>
- struct make_indices<N, indices<I...> >
- : make_indices<N-1, indices<N-1, I...> >
- {};
+ typedef args<
+ typename boost::result_of<G(UNCVREF(E), S, V)>::type
+ > type;
 
- template<int... I>
- struct make_indices<0, indices<I...> >
- {
- typedef indices<I...> type;
+ static typename type::cons_type
+ call(cons<E> const &a, S const &s, V &v)
+ {
+ typename type::cons_type that = {G()(a.car, s, v)};
+ return that;
+ }
             };
 
- template<typename G, typename E, typename S, typename V
- , long GN = G::size, long EN = E::size, bool B = (GN > EN)>
- struct apply_args;
-
- template<typename... G, typename... E, typename S, typename V, long GN, long EN>
- struct apply_args<args<G...>, args<E...>, S, V, GN, EN, false>
- : apply_args<args<G..., typename back<args<G...> >::type>, args<E...>, S, V>
- {};
-
- template<typename... G, typename... E, typename S, typename V, long GN, long EN>
- struct apply_args<args<G...>, args<E...>, S, V, GN, EN, true>
- : apply_args<typename resize<args<G...>, EN>::type, args<E...>, S, V>
- {};
-
- template<typename... G, typename... E, typename S, typename V, long N>
- struct apply_args<args<G...>, args<E...>, S, V, N, N, false>
+ template<typename G1, typename... G2, typename E1, typename... E2, typename S, typename V>
+ struct apply_args<args<G1, G2...>, args<E1, E2...>, S, V>
             {
                 typedef args<
- typename boost::result_of<G(UNCVREF(E), S, V)>::type...
+ typename boost::result_of<G1(UNCVREF(E1), S, V)>::type
+ , typename boost::result_of<G2(UNCVREF(E2), S, V)>::type...
> type;
 
                 static typename type::cons_type
- call(argsns_::cons<E...> const &a, S const &s, V &v)
+ call(cons<E1, E2...> const &a, S const &s, V &v)
                 {
- return apply_args::call_(a, s, v, typename make_indices<sizeof...(E)>::type());
+ typename type::cons_type that = {
+ G1()(a.car, s, v)
+ , apply_args<args<G2...>, args<E2...>, S, V>::call(a.cdr, s, v)
+ };
+ return that;
                 }
+ };
+
+ template<typename G, typename E1, typename... E2, typename S, typename V>
+ struct apply_args<args<G>, args<E1, E2...>, S, V>
+ {
+ typedef args<
+ typename boost::result_of<G(UNCVREF(E1), S, V)>::type
+ , typename boost::result_of<G(UNCVREF(E2), S, V)>::type...
+ > type;
 
- template<int... I>
                 static typename type::cons_type
- call_(argsns_::cons<E...> const &a, S const &s, V &v, indices<I...>)
+ call(cons<E1, E2...> const &a, S const &s, V &v)
                 {
- using result_of::detail::arg_c;
                     typename type::cons_type that = {
- G()(arg_c<argsns_::cons<E...>, I>::call(a), s, v)...
+ G()(a.car, s, v)
+ , apply_args<args<G>, args<E2...>, S, V>::call(a.cdr, s, v)
                     };
                     return that;
                 }
             };
+
+ template<typename G1, typename... G2, typename E, typename S, typename V>
+ struct apply_args<args<G1, G2...>, args<E>, S, V>
+ {
+ typedef args<
+ typename boost::result_of<G1(UNCVREF(E), S, V)>::type
+ > type;
+
+ static typename type::cons_type
+ call(cons<E> const &a, S const &s, V &v)
+ {
+ typename type::cons_type that = {G1()(a.car, s, v)};
+ return that;
+ }
+ };
         }
 
         template<typename T>

Modified: branches/proto/v3/boost/xpressive/proto/transform/fold_tree.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/fold_tree.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/fold_tree.hpp 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
@@ -39,7 +39,6 @@
                   , when<_, Fun>
>
             {};
-
         }
 
         template<typename Sequence, typename State0, typename Fun>
@@ -124,7 +123,6 @@
     struct is_transform<transform::detail::reverse_fold_tree_<Grammar, Fun> >
       : mpl::true_
     {};
-
 }}
 
 #endif

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 13:28:02 EST (Tue, 04 Dec 2007)
@@ -146,7 +146,7 @@
 
         // work around gcc bug
         template<typename T, typename A, long N, typename... Args>
- struct make<expr<T, A, N>, Args... > : transform_base
+ struct make<expr<T, A, N>, Args...> : transform_base
         {
             template<typename Sig>
             struct result

Modified: branches/proto/v3/libs/xpressive/proto/example/hello.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto/example/hello.cpp (original)
+++ branches/proto/v3/libs/xpressive/proto/example/hello.cpp 2007-12-04 13:28:02 EST (Tue, 04 Dec 2007)
@@ -10,7 +10,7 @@
 #include <boost/typeof/std/ostream.hpp>
 using namespace boost;
 
-proto::terminal< std::ostream & >::type cout_ = { std::cout };
+proto::terminal< std::ostream & >::type cout_ = {{std::cout}};
 
 template< typename Expr >
 void evaluate( Expr const & expr )


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