Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64906 - in sandbox/SOC/2010/phoenix3: boost/phoenix/statement boost/phoenix/statement/detail libs/phoenix/example libs/phoenix/test/statement
From: thom.heller_at_[hidden]
Date: 2010-08-18 19:02:49


Author: theller
Date: 2010-08-18 19:02:48 EDT (Wed, 18 Aug 2010)
New Revision: 64906
URL: http://svn.boost.org/trac/boost/changeset/64906

Log:
cleaned up switch statement, g++ 4.2 ICE gone, speedup of 17%
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/detail/switch.hpp | 366 +++++++++------------------------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/switch.hpp | 229 +++++++++++-------------
   sandbox/SOC/2010/phoenix3/libs/phoenix/example/custom_evaluator.cpp | 38 ++-
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp | 3
   4 files changed, 221 insertions(+), 415 deletions(-)

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/detail/switch.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/detail/switch.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/detail/switch.hpp 2010-08-18 19:02:48 EDT (Wed, 18 Aug 2010)
@@ -12,341 +12,147 @@
 #define PHOENIX_STATEMENT_DETAIL_SWITCH_HPP
 
 #include <boost/preprocessor/cat.hpp>
-
- template <typename A0>
- struct switch_eval<A0>
- {
- typedef void result_type;
-
- template <typename Env, typename Cond, typename Case0>
- result_type
- operator()(Env& env, Cond const& cond, Case0 const& case0) const
- {
- switch(eval(cond, env))
- {
- case A0::value: eval(case0, env); break;
- }
- }
- };
-
- template <typename Cond, typename Cases>
- struct make_switch<Cond, Cases, 1, true>
- {
- typedef typename fusion::result_of::value_at_c<Cases, 0>::type case0;
-
- typedef compose<
- switch_default_eval<>
- , Cond
- , typename case0::case_type
- > composite_type;
-
- typedef typename composite_type::type type;
-
- type const
- operator()( Cond const& cond, Cases const& cases) const
- {
- return composite_type()(cond, fusion::at_c<0>(cases).case_);
- }
- };
-
- template <typename A0, typename A1>
- struct switch_eval<A0, A1>
- {
- typedef void result_type;
-
- template <typename Env, typename Cond, typename Case0, typename Case1>
- result_type
- operator()(Env& env, Cond const& cond, Case0 const& case0, Case1 const& case1) const
- {
- switch(eval(cond, env))
- {
- case A0::value: eval(case0, env); break;
- case A1::value: eval(case1, env); break;
- }
- }
- };
     
     template <typename Cond, typename Cases>
- struct make_switch<Cond, Cases, 2, false>
+ struct make_switch<Cond, Cases, 1>
     {
- typedef typename fusion::result_of::value_at_c<Cases, 0>::type case0;
- typedef typename fusion::result_of::value_at_c<Cases, 1>::type case1;
+ typedef typename result_of::case_compound<Cases, mpl::int_<0> >::type case0;
 
- typedef compose<
- switch_eval<typename case0::value_type, typename case1::value_type >
- , Cond
- , typename case0::case_type
- , typename case1::case_type
- > composite_type;
+ typedef
+ compose<
+ switch_eval
+ , Cond
+ , case0
+ >
+ composite_type;
 
         typedef typename composite_type::type type;
-
- type const
- operator()( Cond const& cond, Cases const& cases) const
- {
- return composite_type()(cond, fusion::at_c<0>(cases).case_, fusion::at_c<1>(cases).case_);
- }
- };
-
- template <typename A0, typename A1, typename A2>
- struct switch_eval<A0, A1, A2>
- {
- typedef void result_type;
-
- template <typename Env, typename Cond, typename Case0, typename Case1, typename Case2>
- result_type
- operator()(Env& env, Cond const& cond, Case0 const& case0, Case1 const& case1, Case2 const& case2) const
- {
- switch(eval(cond, env))
- {
- case A0::value: eval(case0, env); break;
- case A1::value: eval(case1, env); break;
- case A2::value: eval(case2, env); break;
- }
- }
- };
-
- template <typename Cond, typename Cases>
- struct make_switch<Cond, Cases, 3, false>
- {
- typedef typename fusion::result_of::value_at_c<Cases, 0>::type case0;
- typedef typename fusion::result_of::value_at_c<Cases, 1>::type case1;
- typedef typename fusion::result_of::value_at_c<Cases, 2>::type case2;
-
- typedef compose<
- switch_eval<typename case0::value_type, typename case1::value_type, typename case2::value_type >
- , Cond
- , typename case0::case_type
- , typename case1::case_type
- , typename case2::case_type
- > composite_type;
 
- typedef typename composite_type::type type;
-
         type const
         operator()( Cond const& cond, Cases const& cases) const
         {
- return composite_type()(cond, fusion::at_c<0>(cases).case_, fusion::at_c<1>(cases).case_, fusion::at_c<2>(cases).case_);
+ return composite_type()(cond, case_compound_c<0>(cases));
         }
     };
 
- template<>
- struct switch_default_eval<>
+ struct switch_eval
     {
         typedef void result_type;
-
- template <typename Env, typename Cond, typename Default>
- result_type
- operator()(Env& env, Cond const& cond, Default const& default_) const
+
+ template <typename Env, typename Cond, typename Case0>
+ void
+ operator()(Env& env, Cond const& cond, Case0 const& case0) const
         {
- switch(eval(cond, env))
- {
- default: eval(default_, env); break;
- }
+ return evaluate(env, cond, case0, result_of::is_default_case<Case0>());
         }
- };
-
- template <typename Cond, typename Cases>
- struct make_switch<Cond, Cases, 1, false>
- {
- typedef typename fusion::result_of::value_at_c<Cases, 0>::type case0;
-
- typedef compose<
- switch_eval<typename case0::value_type >
- , Cond
- , typename case0::case_type
- > composite_type;
-
- typedef typename composite_type::type type;
         
- type const
- operator()( Cond const& cond, Cases const& cases) const
+ template <typename Env, typename Cond, typename Case0>
+ void
+ evaluate(Env& env, Cond const& cond, Case0 const& case0, mpl::false_) const
         {
- return composite_type()(cond, fusion::at_c<0>(cases).case_);
- }
- };
+ typedef typename result_of::case_label<Case0>::type label0;
 
- template<typename A0>
- struct switch_default_eval<A0>
- {
- typedef void result_type;
-
- template <typename Env, typename Cond, typename Case0, typename Default>
- result_type
- operator()(Env& env, Cond const& cond, Case0 const& case0, Default const& default_) const
- {
             switch(eval(cond, env))
             {
- case A0::value: eval(case0, env); break;
- default: eval(default_, env); break;
+ case label0::value: eval(case_statement(case0), env); break;
             }
         }
- };
-
- template <typename Cond, typename Cases>
- struct make_switch<Cond, Cases, 2, true>
- {
- typedef typename fusion::result_of::value_at_c<Cases, 0>::type case0;
- typedef typename fusion::result_of::value_at_c<Cases, 1>::type case1;
-
- typedef compose<
- switch_default_eval<typename case0::value_type>
- , Cond
- , typename case0::case_type
- , case1
- > composite_type;
-
- typedef typename composite_type::type type;
         
- type const
- operator()( Cond const& cond, Cases const& cases) const
- {
- return composite_type()(cond, fusion::at_c<0>(cases).case_, fusion::at_c<1>(cases).case_);
- }
- };
-
- template<typename A0, typename A1>
- struct switch_default_eval<A0, A1>
- {
- typedef void result_type;
-
- template <typename Env, typename Cond, typename Case0, typename Case1, typename Default>
- result_type
- operator()(Env& env, Cond const& cond, Case0 const& case0, Case1 const& case1, Default const& default_) const
+ template <typename Env, typename Cond, typename Case0>
+ void
+ evaluate(Env& env, Cond const& cond, Case0 const& case0, mpl::true_) const
         {
             switch(eval(cond, env))
             {
- case A0::value: eval(case0, env); break;
- case A1::value: eval(case1, env); break;
- default: eval(default_, env); break;
+ default: eval(proto::child(case0), env); break;
             }
         }
- };
-
- template <typename Cond, typename Cases>
- struct make_switch<Cond, Cases, 3, true>
- {
- typedef typename fusion::result_of::value_at_c<Cases, 0>::type case0;
- typedef typename fusion::result_of::value_at_c<Cases, 1>::type case1;
- typedef typename fusion::result_of::value_at_c<Cases, 2>::type case2;
-
- typedef compose<
- switch_default_eval<typename case0::value_type, typename case1::value_type>
- , Cond
- , typename case0::case_type
- , typename case1::case_type
- , typename case2::case_type
- > composite_type;
 
- typedef typename composite_type::type type;
-
- type const
- operator()( Cond const& cond, Cases const& cases) const
- {
- return composite_type()(cond, fusion::at_c<0>(cases).case_, fusion::at_c<1>(cases).case_, fusion::at_c<2>(cases).case_);
- }
+#define PHOENIX_SWITCH_EVAL_LABEL_TYPEDEF(_,n,__)\
+ typedef typename result_of::case_label<BOOST_PP_CAT(A, n)>::type BOOST_PP_CAT(label, n);
+
+#define PHOENIX_SWITCH_EVAL_CASE_EVAL(_,n,__)\
+ case BOOST_PP_CAT(label,n)::value: eval(case_statement(BOOST_PP_CAT(a, n)), env); break;
+
+
+#define PHOENIX_SWITCH_EVAL_OVERLOADS(_,n,__) \
+ template <typename Env, typename Cond, PHOENIX_typename_A(n)> \
+ void \
+ operator()(Env& env, Cond const& cond, PHOENIX_A_const_ref_a(n)) const \
+ { \
+ return evaluate(env, cond, PHOENIX_a(n), result_of::is_default_case<BOOST_PP_CAT(A, BOOST_PP_DEC(n))>()); \
+ }\
+ \
+ template <typename Env, typename Cond, PHOENIX_typename_A(n)>\
+ void\
+ evaluate(Env& env, Cond const& cond, PHOENIX_A_const_ref_a(n), mpl::false_) const\
+ {\
+ BOOST_PP_REPEAT(n, PHOENIX_SWITCH_EVAL_LABEL_TYPEDEF, _)\
+ switch(eval(cond, env))\
+ {\
+ BOOST_PP_REPEAT(n, PHOENIX_SWITCH_EVAL_CASE_EVAL, _)\
+ }\
+ }\
+ \
+ template <typename Env, typename Cond, PHOENIX_typename_A(n)>\
+ void\
+ evaluate(Env& env, Cond const& cond, PHOENIX_A_const_ref_a(n), mpl::true_) const\
+ {\
+ BOOST_PP_REPEAT(BOOST_PP_DEC(n), PHOENIX_SWITCH_EVAL_LABEL_TYPEDEF, _)\
+ switch(eval(cond, env))\
+ {\
+ BOOST_PP_REPEAT(BOOST_PP_DEC(n), PHOENIX_SWITCH_EVAL_CASE_EVAL, _)\
+ default: eval(proto::child(BOOST_PP_CAT(a, BOOST_PP_DEC(n))), env); break;\
+ }\
+ }
+
+ BOOST_PP_REPEAT_FROM_TO(2, PHOENIX_COMPOSITE_LIMIT, PHOENIX_SWITCH_EVAL_OVERLOADS, _)
+
+#undef PHOENIX_SWITCH_EVAL_LABEL_TYPEDEF
+#undef PHOENIX_SWITCH_EVAL_CASE_EVAL
+#undef PHOENIX_SWITCH_EVAL_OVERLOADS
     };
 
 #define PHOENIX_ITERATION_PARAMS \
- (3, (4, PHOENIX_COMPOSITE_LIMIT, \
+ (3, (2, PHOENIX_COMPOSITE_LIMIT, \
     <boost/phoenix/statement/detail/switch.hpp>))
 #include PHOENIX_ITERATE()
 
+
 #endif
 
 #else
 
-#define PHOENIX_typename_CaseCond BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, typename CaseCond)
-#define PHOENIX_CaseCond BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, CaseCond)
-#define PHOENIX_typename_CaseCond_default BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(PHOENIX_ITERATION), typename CaseCond)
-#define PHOENIX_CaseCond_default BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(PHOENIX_ITERATION), CaseCond)
-
- template <PHOENIX_typename_CaseCond>
- struct switch_eval<PHOENIX_CaseCond>
- {
- typedef void result_type;
-
- template <typename Env, typename Cond, PHOENIX_typename_A>
- result_type
- operator()(Env& env, Cond const& cond, PHOENIX_A_const_ref_a) const
- {
-#define CASES(_,n,__) case CaseCond ## n ::value : eval( a ##n, env ); break;
-
- switch(eval(cond, env))
- {
- BOOST_PP_REPEAT(PHOENIX_ITERATION, CASES, _)
- }
- }
- };
-
     template <typename Cond, typename Cases>
- struct make_switch<Cond, Cases, PHOENIX_ITERATION, false>
+ struct make_switch<Cond, Cases, PHOENIX_ITERATION>
     {
-#define CASE_TYPEDEF(_,n,__) typedef typename fusion::result_of::value_at_c<Cases, n>::type case ## n;
+#define CASE_TYPEDEF(_,n,__) \
+ typedef typename result_of::case_compound<Cases, mpl::int_< n > >::type BOOST_PP_CAT(case, n);
         BOOST_PP_REPEAT(PHOENIX_ITERATION, CASE_TYPEDEF, _)
 
- typedef compose<
- switch_eval<BOOST_PP_ENUM_BINARY_PARAMS(PHOENIX_ITERATION, typename case, ::value_type BOOST_PP_INTERCEPT)>
- , Cond
- , BOOST_PP_ENUM_BINARY_PARAMS(PHOENIX_ITERATION, typename case, ::case_type BOOST_PP_INTERCEPT)
- > composite_type;
+ typedef
+ compose<
+ switch_eval
+ , Cond
+ , BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, case)
+ >
+ composite_type;
 
         typedef typename composite_type::type type;
-
- type const
- operator()( Cond const& cond, Cases const& cases) const
- {
-#define FUSION_AT_C(_, n, __) BOOST_PP_COMMA_IF(n) fusion::at_c< n >(cases).case_
- return composite_type()(cond,
- BOOST_PP_REPEAT(PHOENIX_ITERATION, FUSION_AT_C, _));
- }
- };
 
- template <PHOENIX_typename_CaseCond_default>
- struct switch_default_eval<PHOENIX_CaseCond_default>
- {
- typedef void result_type;
-
- template <typename Env, typename Cond, PHOENIX_typename_A>
- result_type
- operator()(Env& env, Cond const& cond, PHOENIX_A_const_ref_a) const
- {
- switch(eval(cond, env))
- {
- BOOST_PP_REPEAT(BOOST_PP_DEC(PHOENIX_ITERATION), CASES, _)
- default: eval(BOOST_PP_CAT(a, BOOST_PP_DEC(PHOENIX_ITERATION)), env);
- }
- }
- };
-
- template <typename Cond, typename Cases>
- struct make_switch<Cond, Cases, PHOENIX_ITERATION, true>
- {
- BOOST_PP_REPEAT(PHOENIX_ITERATION, CASE_TYPEDEF, _)
-
- typedef compose<
- switch_default_eval<BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_DEC(PHOENIX_ITERATION), typename case, ::value_type BOOST_PP_INTERCEPT)>
- , Cond
- , BOOST_PP_ENUM_BINARY_PARAMS(PHOENIX_ITERATION, typename case, ::case_type BOOST_PP_INTERCEPT)
- > composite_type;
-
- typedef typename composite_type::type type;
-
         type const
         operator()( Cond const& cond, Cases const& cases) const
         {
- return composite_type()(cond,
- BOOST_PP_REPEAT(PHOENIX_ITERATION, FUSION_AT_C, _));
+ return composite_type()(
+ cond,
+#define CASE_COMPOUND(_,n,__)\
+ BOOST_PP_COMMA_IF(n) case_compound_c< n >(cases)
+ BOOST_PP_REPEAT(PHOENIX_ITERATION, CASE_COMPOUND, _));
         }
     };
 
-#undef FUSION_AT_C
 #undef CASE_TYPEDEF
-#undef CASES
-#undef PHOENIX_typename_CaseCond
-#undef PHOENIX_CaseCond
-#undef PHOENIX_typename_CaseCond_default
-#undef PHOENIX_CaseCond_default
+#undef CASE_COMPOUND
 
 #endif
 

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/switch.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/switch.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/switch.hpp 2010-08-18 19:02:48 EDT (Wed, 18 Aug 2010)
@@ -8,10 +8,6 @@
 #ifndef PHOENIX_STATEMENT_SWITCH_HPP
 #define PHOENIX_STATEMENT_SWITCH_HPP
 
-#include <boost/fusion/algorithm/transformation/push_front.hpp>
-#include <boost/fusion/container/vector/convert.hpp>
-#include <boost/fusion/sequence/intrinsic/at.hpp>
-#include <boost/fusion/sequence/intrinsic/value_at.hpp>
 #include <boost/phoenix/core/limits.hpp>
 #include <boost/phoenix/core/meta_grammar.hpp>
 #include <boost/phoenix/core/compose.hpp>
@@ -28,127 +24,132 @@
     struct switch_case_tag {};
     struct switch_default_tag {};
 
- template <typename Value, typename Case>
- struct switch_case
- {
- typedef Value value_type;
- typedef Case case_type;
-
- switch_case(Case const& case_) : case_(case_) {};
-
- Case const& case_;
- };
-
- template <typename Case>
- struct switch_default
- {
- typedef mpl::false_ value_type;
- typedef Case case_type;
-
- switch_default(Case const& case_) : case_(case_) {};
-
- Case const& case_;
- };
-
     namespace detail
     {
- struct push_front
- : proto::callable
- {
- template <typename Sig>
- struct result;
+ struct case_label
+ : proto::terminal<proto::_>
+ {};
 
- template <typename This, typename Expr, typename State>
- struct result<This(Expr, State)>
- : fusion::result_of::push_front<
- typename remove_const<
- typename remove_reference<State>::type
- >::type const
- , typename remove_const<
- typename remove_reference<Expr>::type
- >::type
- >
- {};
-
- template <typename Expr, typename State>
- typename fusion::result_of::push_front<
- typename remove_const<
- typename remove_reference<State>::type
- >::type const
- , typename remove_const<
- typename remove_reference<Expr>::type
- >::type
- >::type
- operator()(Expr expr, State state) const
- {
- return fusion::push_front(state, expr);
- }
- };
-
- template <typename Case>
- struct is_default
- : mpl::false_
+ struct case_statement
+ : proto::binary_expr<switch_case_tag, case_label, eval_grammar>
         {};
 
- template <typename Case>
- struct is_default<switch_default<Case> >
- : mpl::true_
+ struct default_statement
+ : proto::unary_expr<switch_default_tag, eval_grammar>
         {};
- }
 
- struct switch_grammar
- : /// FIXME
- /*proto::and_<
- // switch_(...)[default_(...), default_(...)] not allowed
- proto::not_<
- proto::comma<
- proto::unary_expr<switch_default_tag, eval_grammar>
- , proto::unary_expr<switch_default_tag, eval_grammar>
+ struct switch_size
+ : proto::or_<
+ proto::when<
+ proto::comma<switch_size, proto::_>
+ , mpl::next<switch_size(proto::_left)>()
>
+ , proto::when<proto::_, mpl::int_<1>()>
>
- // switch_(...)[case_<...>(...), default_(...), case<...>(...)] not allowed
- , proto::not_<
- proto::comma<proto::comma<switch_grammar, proto::unary_expr<switch_default_tag, eval_grammar> >, switch_grammar >
- >
- // switch_(...)[case_<...>(...), default_(...), default_(...)] not allowed
- , proto::not_<
- proto::comma<proto::comma<switch_grammar, proto::unary_expr<switch_default_tag, eval_grammar> >, proto::unary_expr<switch_default_tag, eval_grammar> >
- >
- // and finally the transforms to create the fusion vector of the actors
- ,*/ proto::or_<
+ {};
+
+ struct switch_has_default
+ : proto::or_<
                 proto::when<
- proto::comma<switch_grammar, switch_grammar>
- , switch_grammar(proto::_left, switch_grammar(proto::_right))
+ proto::comma<switch_size, case_statement>
+ , mpl::false_()
+ >
+ , proto::when<
+ proto::comma<switch_size, default_statement>
+ , mpl::true_()
>
               , proto::when<
- proto::binary_expr<switch_case_tag, proto::_, eval_grammar>
- , detail::push_front(
- switch_case<
- proto::_value(proto::_left)
- , proto::_right
- >(proto::_right)
- , proto::_state)
+ case_statement
+ , mpl::false_()
>
               , proto::when<
- proto::unary_expr<switch_default_tag, eval_grammar>
- , detail::push_front(
- switch_default<proto::_child>(proto::_child)
- , proto::_state)
+ default_statement
+ , mpl::true_()
>
>
- //>
- {};
+ {};
 
- template <PHOENIX_typename_A_void(PHOENIX_COMPOSITE_LIMIT), typename Dummy = void>
- struct switch_eval;
+ struct switch_case_statement
+ : proto::or_<
+ proto::when<
+ proto::comma<switch_case_statement, proto::_>
+ , proto::if_<
+ is_same<mpl::prior<proto::_data>(), proto::_state>()
+ , proto::_right
+ , switch_case_statement(proto::_left, proto::_state, mpl::prior<proto::_data>())
+ >
+ >
+ , proto::otherwise<proto::_>
+ >
+ {};
+ }
+
+ namespace result_of
+ {
+ template <typename Cases>
+ struct cases_size : boost::result_of<detail::switch_size(Cases)> {};
 
- template <PHOENIX_typename_A_void(BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT)), typename Dummy = void>
- struct switch_default_eval;
+ template <typename Cases, typename N>
+ struct case_compound
+ : mpl::eval_if<
+ mpl::less<N, typename cases_size<Cases>::type >
+ , boost::result_of<detail::switch_case_statement(Cases, N, typename cases_size<Cases>::type)>
+ , mpl::void_
+ >
+ {};
+
+ template <typename Case>
+ struct case_statement
+ : proto::result_of::right<Case>
+ {};
+
+ template <typename Case>
+ struct case_label
+ : proto::result_of::value<
+ typename proto::result_of::left<
+ Case
+ >::type
+ >
+ {};
+
+ template <typename Cases>
+ struct switch_has_default : boost::result_of<detail::switch_has_default(Cases)> {};
+
+ template <typename Case>
+ struct is_default_case
+ : proto::matches<Case, detail::default_statement>
+ {};
+ }
+
+ template <int N, typename Cases>
+ typename result_of::case_compound<Cases, mpl::int_<N> >::type const &
+ case_compound_c(Cases const& cases)
+ {
+ typename result_of::cases_size<Cases>::type size;
+ return detail::switch_case_statement()(cases, mpl::int_<N>(), size);
+ }
+
+ template <typename N, typename Cases>
+ typename result_of::case_compound<Cases, N>::type const &
+ case_compound(Cases const& cases)
+ {
+ typename result_of::cases_size<Cases>::type size;
+ return detail::switch_case_statement()(cases, N(), size);
+ }
+
+ template <typename Case>
+ typename result_of::case_statement<Case>::type const &
+ case_statement(Case const& case_)
+ {
+ return proto::right(case_);
+ }
+
+ struct switch_eval;
 
     template <
         typename Cond,
- typename Cases, int N = fusion::result_of::size<Cases>::type::value,
- bool with_default = detail::is_default<typename fusion::result_of::value_at_c<Cases, N-1>::type >::value,
+ typename Cases,
+ int N = result_of::cases_size<Cases>::type::value,
         typename Dummy = void>
     struct make_switch;
 
@@ -205,27 +206,13 @@
         template <typename Cases>
         typename make_switch<
             Cond
- , typename fusion::result_of::as_vector<
- //typename switch_grammar::impl<Cases const&, fusion::vector0<>&,int>::result_type
- typename boost::result_of<
- switch_grammar(Cases const&, fusion::vector0<>&)
- >::type
- >::type
+ , Cases
>::type
         operator[](Cases const& cases) const
         {
- BOOST_PROTO_ASSERT_MATCHES( cases, switch_grammar );
- typedef
- typename fusion::result_of::as_vector<
- //typename switch_grammar::impl<Cases const&, fusion::vector0<>&,int>::result_type
- typename boost::result_of<
- switch_grammar(Cases const&, fusion::vector0<>&)
- >::type
- >::type
- cases_type;
+ BOOST_PROTO_ASSERT_MATCHES(cases, detail::switch_case_statement);
 
- fusion::vector0<> v;
- return make_switch<Cond, cases_type>()(cond, fusion::as_vector(switch_grammar()(cases, v)));
+ return make_switch<Cond, Cases>()(cond, cases);
         }
 
         Cond const& cond;

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/example/custom_evaluator.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/example/custom_evaluator.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/example/custom_evaluator.cpp 2010-08-18 19:02:48 EDT (Wed, 18 Aug 2010)
@@ -1,5 +1,4 @@
 /*==============================================================================
- Copyright (c) 2005-2010 Joel de Guzman
     Copyright (c) 2010 Thomas Heller
 
     Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -69,9 +68,9 @@
 
             result_type operator()(Expr &expr, phoenix_to_cpp &ctx) const
             {
- ctx.ostr << std::setw(ctx.level*4) << " "; proto::eval(proto::child_c<0>(expr), ctx);
+ /*ctx.ostr << std::setw(ctx.level*4) << " ";*/ proto::eval(proto::child_c<0>(expr), ctx);
                 ctx.ostr << ";\n";
- ctx.ostr << std::setw(ctx.level*4) << " "; proto::eval(proto::child_c<1>(expr), ctx);
+ /*ctx.ostr << std::setw(ctx.level*4) << " ";*/ proto::eval(proto::child_c<1>(expr), ctx);
                 ctx.ostr << ";";
 
                 return ctx.ostr;
@@ -83,12 +82,30 @@
         {
             typedef OutStream& result_type;
             
- template <typename N, typename E>
- void output(OutStream& os, E &expr) const {}
+ template <typename E>
+ void output(OutStream& os, E const& expr) const
+ {
+ std::cout << typeid( expr ).name() << "\n\n";
+ std::cout << typeid( typename phoenix::make_argument<boost::mpl::int_<0> >::type ).name() << "\n\n";
+ }
 
- template <typename N, typename Env>
- void output(OutStream& os,
- phoenix::actor<
+ void output(OutStream& os, typename phoenix::make_argument<boost::mpl::int_<0> >::type const& expr)
+ {
+ os << "arg" << 0;
+ }
+ void output(OutStream& os, typename phoenix::make_argument<boost::mpl::int_<1> >::type const& expr)
+ {
+ os << "arg" << 1;
+ }
+ void output(OutStream& os, typename phoenix::make_argument<boost::mpl::int_<2> >::type const& expr)
+ {
+ os << "arg" << 2;
+ }
+ void output(OutStream& os, typename phoenix::make_argument<boost::mpl::int_<3> >::type const& expr)
+ {
+ os << "arg" << 3;
+ }
+ /*phoenix::actor<
                         proto::basic_expr<
                             boost::proto::tag::function
                           , proto::list3<
@@ -103,10 +120,7 @@
>
>
>
- > const& expr) const
- {
- os << "arg" << N::value;
- }
+ > const& expr) const */
 
             result_type operator()(Expr &expr, phoenix_to_cpp &ctx) const
             {

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/statement/switch_tests.cpp 2010-08-18 19:02:48 EDT (Wed, 18 Aug 2010)
@@ -39,7 +39,6 @@
     );
 
     cout << endl;
-
     for_each(v.begin(), v.end(),
         switch_(_1)
         [
@@ -49,7 +48,7 @@
     );
 
     cout << endl;
-
+
     for_each(v.begin(), v.end(),
         switch_(_1)
         [


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