Boost logo

Boost Users :

Subject: Re: [Boost-users] [phoenix] v3 extension mechanism for template functions
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-04-19 00:55:34

On Apr 18, 8:34 pm, alfC <alfredo.cor..._at_[hidden]> wrote:
> Hi,
>  In Phoenix2 I used to have the following code to add expressions of
> type pow<N>(... expr...) which where useful for expressions involving
> Boost.Units. Is it possible to do something similar with Phoenix3. The
> usage if macros in the tutorial examples obscures how to add template
> parameters to the phoenix expression. In Phoenix2 it was straight
> forward, but I can figure out how to do this in Phoenix3.

ok, this is the farthest I could go with Phoenix3. It seems that the
tag:: struct argument in phoenix::expr is a template template.

The following is the latest attempt, which doesn't compile, giving the
boost/phoenix/core/is_nullary.hpp:124:9: error: base type ‘const
boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >,
1l>&’ fails to be a struct or class type

namespace boost{
        namespace phoenix{
                namespace tag{
                        template<long N>
                        struct pow{};

                namespace expression
                    template <long N, typename A0>
                    struct pow
                        : boost::phoenix::expr<
                          , A0
        namespace phoenix_impl{
                template<long N>
                struct pow_impl{
                        template<class Sig> struct result;
                        template<class This, class Arg, class Cont>
                        struct result<This(Arg, Cont)>{
                                typedef double type; // just for testing
                        template<class Arg, class Cont>
                        typename result<pow_impl(Arg const&, Cont const&)>::type
                        operator()(Arg const& arg, Cont const& ctx) const {
                                return boost::units::pow<N>(eval(arg, ctx)).value(); //value, just
for testing
        namespace phoenix{
                template <long N, typename Arg>
                typename expression::pow<N, Arg>::type const
                pow(Arg const& arg){
                        return expression::pow<N, Arg>::make(arg);

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