Boost logo

Boost Users :

Subject: Re: [Boost-users] [phoenix] v3 extension mechanism for template functions
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-04-20 02:58:43

On Apr 18, 10:05 pm, Thomas Heller <thom.hel..._at_[hidden]> 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.


#include <boost/phoenix/core/limits.hpp>
#include <boost/phoenix/core/expression.hpp>
#include <boost/phoenix/core/meta_grammar.hpp>
#include <boost/type_traits/remove_reference.hpp>


  , (proto::terminal<proto::_>)

namespace boost{
        namespace phoenix{
                struct pow_eval{
                        BOOST_PROTO_CALLABLE() //what for?
                        template<typename Sig> struct result;
                        template<typename This, typename Seq, typename N>
                        struct result<This(Seq, N)>{
                                typedef typename boost::units::power_typeof_helper<
                                        typename boost::remove_const<typename
>::type type;
                        template<typename Seq, typename N>
                        typename result<pow_eval(Seq, N)>::type
                        operator()(Seq const &seq, N const&) const{
                                using namespace boost::units;
                                return pow<N::value>(seq);
                template <typename Dummy>
                struct default_actions::when<rule::pow, Dummy>
                : proto::call<
                                , proto::_value(proto::_child_c<0>)
                template<long N, typename Arg>
                typename expression::pow<mpl::int_<N>, Arg>::type const
                pow(Arg const& arg){
                        return expression::pow<mpl::int_<N>, Arg>::make(mpl::int_<N>(),

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at