On Apr 18, 10:05 pm, Thomas Heller wrote:
Well. the intention was to not obscure but ease the process of adding new
expressions. Your hint has been noted, i will explain what this macro does
with an example.
makes sense. Following your steps and the code base in
boost/phoenix/fusion/at.hpp and boost/proto/functional/fusion/at.hpp
I was able to add the pow<N>(...) expression (which works for
boost.units, and doubles), see below.
Thanks,
#include
#include
#include
#include
#include
#include
#define BOOST_MPL_LIMIT_METAFUNCTION_ARITY 5
#include
BOOST_PHOENIX_DEFINE_EXPRESSION(
(boost)(phoenix)(pow)
, (proto::terminalproto::_)
(meta_grammar)
)
namespace boost{
namespace phoenix{
struct pow_eval{
BOOST_PROTO_CALLABLE() //what for?
template<typename Sig> struct result;
template
struct result{
typedef typename boost::units::power_typeof_helper<
typename boost::remove_const::type,
boost::units::static_rational
>::type type;
};
template
typename result::type
operator()(Seq const &seq, N const&) const{
using namespace boost::units;
return pow(seq);
}
};
template <typename Dummy>
struct default_actions::when
: proto::call<
pow_eval(
evaluator(proto::_child_c<1>)
, proto::_value(proto::_child_c<0>)
)
>
{};
template
typename expression::pow::type const
pow(Arg const& arg){
return expression::pow::make(mpl::int_<N>(),
arg);
}
}
}