[phoenix] v3 extension mechanism for template functions

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.
// phoenix2 code:
#include

On Apr 18, 8:34 pm, alfC
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
error:
boost/phoenix/core/is_nullary.hpp:124:9: error: base type ‘const
boost::proto::exprns_::basic_expr

On Tue, Apr 19, 2011 at 5:34 AM, alfC
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.
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.
In Phoenix2 it was straight forward, but I can figure out how to do this in Phoenix3.
The process is simple: 1) Define the expression, this means: 1.1) Define how the proto expression will look like 1.2) Define what expressions will match 1.3) Hook the expression up in the Actions mechanism This is done by the macro. Cause the code for that will look almost the same everytime. 2) Define what's to be done in the default_actions (usually call some other functor with the expressions children) 3) Write a generation function. Please have a look at: http://svn.boost.org/svn/boost/trunk/boost/phoenix/fusion/at.hpp

On Apr 18, 10:05 pm, Thomas Heller
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

On Apr 19, 11:58 pm, alfC
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.
BTW, using (note the actor<...> pattern (see below) nicely lifts an
ambiguity between boost::units::pow and the newly created
boost::phoenix::pow.
I hope the boost.units maintainers take now and include an adaptor
like this to boost/units/phoenix.hpp
template ::make(mpl::int_<N>(), arg);
} Thanks,
Alfredo
participants (2)
-
alfC
-
Thomas Heller