Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] Forwarding evaluation via tag
From: joel (joel.falcou_at_[hidden])
Date: 2009-09-29 13:35:50


> You'll have to post your code ... I can't tell what problem you might
> be running into.
Well, I decided to be a coward for today. I'll shelf this functional
solution for later. I just added
my own ternary_expr & quaternary_expr class for the moment as it seems
it's all the client wants.
I'll come back when I've digested those infos as I htink I'm just doing
a small error.

For reference here is the code I wrote:

  namespace bp = boost::proto;

  struct push_front_
  {
    template<class Sig> struct result;
    template<class This,class Seq,class Elem>
    struct result<This(Seq,Elem)>
    {
      typedef typename
boost::fusion::result_of::push_front<Seq,Elem>::type type;
    };

    template<class Seq,class Elem>
    typename result<push_front_(Seq,Elem)>::type
    operator()(Elem const& e, Seq& s ) const
    {
      return boost::fusion::push_front(s,e);
    }
  };

  struct _load : bp::transform< _load >
  {
    template<typename Expr, typename State, typename Data>
    struct impl : bp::transform_impl<Expr, State, Data>
    {
      typedef typename meta::strip<Expr>::type::value_type result_type;

      result_type operator()( typename impl::expr_param expr
                            , typename impl::state_param
                            , typename impl::data_param data
                            ) const
      {
        return expr(data);
      }
    };
  };

  struct eval_xpr
        : bp::or_< bp::when< bp::terminal< block<bp::_,bp::_> >
                           , _load(bp::_)
>
                 , bp::when< bp::nary_expr< bp::_, bp::vararg<eval_xpr> >
                         , bp::functional::unpack_expr<bp::tag::function>(
                              push_front_(bp::_,
bp::terminal<functor<bp::tag_of<bp::_> > >() )
                                                                          
)
                                                                )
>
> {};

-- 
___________________________________________
Joel Falcou - Assistant Professor
PARALL Team - LRI - Universite Paris Sud XI
Tel : (+33)1 69 15 66 35

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net