|
Boost Users : |
Subject: [Boost-users] [phoenix] v2 to v3 transition of extension mechanism
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-04-12 01:59:13
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 here
https://svn.boost.org/svn/boost/sandbox/SOC/2010/phoenix3/libs/phoenix/doc/html/phoenix/examples/adding_an_expression.html)
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 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