|
Boost : |
From: Larry Evans (cppljevans_at_[hidden])
Date: 2007-06-01 07:35:43
Hi Eric,
I need a context with something like the following methods:
template< typename Tag, typename Left, typename Right >
result_type operator()(expr<Tag, Left, Right> const &expr) const
{
std::cout<<std::setw(indent)
<<""<<"binary_expr:"<<expr.get_instance()<<"\n";
indent+=2;
proto::eval(left, *this);
proto::eval(right, *this);
indent-=2;
}
where the expression tree node argument remains "packaged":
(expr<Tag, Left, Right> const &expr)
in contrast to the unpacked version:
(Tag, Left const &left, Right const &right)
shown in, for example:
http://boost-sandbox.sourceforge.net/libs/proto/doc/html/boost_proto/user_s_guide/calculator.html
IOW, the calculator.html page suggests an interface like:
template< typename Tag, typename Left, typename Right >
result_type operator()(Tag, Left const &left, Right const &right) const
{
std::cout<<std::setw(indent)<<""<<"binary_expr\n";
indent+=2;
proto::eval(left, *this);
proto::eval(right, *this);
indent-=2;
}
where there's no access to the "packaged" extended node,
expr<Tag,Left,Right>, where the extension is, for example:
struct xmpl_domain;
struct xmpl_delta
{
unsigned const my_instance;
static unsigned our_instances;
xmpl_delta(void)
: my_instance(++our_instances)
{}
xmpl_delta(xmpl_delta const&)
: my_instance(++our_instances)
{}
void operator=(xmpl_delta const&)
{}
unsigned get_instance(void)const
{
return my_instance;
}
};
unsigned xmpl_delta::our_instances=0;
template<typename Expr>
struct xmpl_expression
: proto::extends<Expr, xmpl_expression<Expr>, xmpl_domain>
, xmpl_delta
{ ... };
I've looked at the formated output of the preprocessed context.hpp;
however, I'm still having difficulty figuring out if this
"packaged" method interfaces is possible.
Any help is appreciated.
TIA.
-regards,
Larry
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk