Boost logo

Boost Users :

Subject: Re: [Boost-users] [phoenix] v2 to v3 transition of extension mechanism
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-04-12 02:14:34


jeje, I just found boost/phoenix/stdlib/cmath.hpp which exactly
implements a lazy 'cos' function.

Anyway it would be good to understand what I was missing in my
implementation since the
boost/phoenix/stdlib/cmath.hpp (by Steven Watanabe) seems to have some
complicated MACRO magic in it.

Thanks,
Alfredo

On Apr 11, 10:59 pm, alfC <alfredo.cor..._at_[hidden]> wrote:
> Hi, I am updating some of my code to use Phoenix3 instead of
> Phoenix2.
>
> For example in Phoenix2 I used to have this extension to support
> 'cos(...)' expressions:
>
> namespace boost{
> namespace phoenix{
>         struct cos_eval{
>                 template<class Env, typename Arg_> struct result{typedef double
> type;};
>                 template<class RT, typename Env, typename Arg_> static RT eval(Env
> const& env, Arg_ const& arg_){
>                         return cos(arg_.eval(env));
>                 }
>         };
>         template<typename Arg_>
>         void cos(Arg_ const& arg_){
>                 return compose<cos_eval>(arg_);
>         }
>
> }}
>
> In Phoenix3, if I followed things correctly (from herehttps://svn.boost.org/svn/boost/sandbox/SOC/2010/phoenix3/libs/phoeni...)
> the new framework ask for the following, which doesn't work. The error
> (see at end) is difficult to decipher. What am I missing to implement
> this simple expression extension? -- Thanks.
>
> #include<boost/phoenix/phoenix.hpp>       //v3
> BOOST_PHOENIX_DEFINE_EXPRESSION(
>     (boost)(phoenix)(cos_)
>   , (meta_grammar)           // Arg
> )
>
> namespace boost { namespace phoenix
> {
>         struct cos_eval{
>                 typedef double result_type;
>
>                 template <typename Context, typename Arg>
>                 result_type
>                 operator()(Context const& ctx, Arg const& arg) const{
>                     return std::cos(eval(arg, ctx));
>                 }
>         };
>
>         template <typename Dummy>
>         struct default_actions::when<rule::cos_, Dummy>
>                 : call<cos_eval, Dummy>
>         {};
>
>         template <typename Arg>
>         typename expression::cos_<Arg>::type const
>         cos_(Arg const& arg){
>                 return expression::cos_<Arg>::make(arg);
>         }
>
> }}
>
> usr/include/boost/proto/matches.hpp:846:13: error: no type named
> ‘proto_tag’ in ‘const struct
> boost::phoenix::vector2<boost::phoenix::vector2<const
> boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::tag::cos_,
> boost::proto::argsns_::list1<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tag::terminal,
> boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >,
> 1l> >*, double&>&, const boost::phoenix::default_actions&>’
> compilation terminated due to -Wfatal-errors.
> _______________________________________________
> Boost-users mailing list
> Boost-us..._at_[hidden]http://lists.boost.org/mailman/listinfo.cgi/boost-users


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