<snip>
Not necessarily. These these can be added to your DSEL post-hoc, and there
are some fun games you can play with proto's operator->*. Consider the
following program:
Thanks, Eric. That was an Ah-ha moment for me. I tried a different
variation of your program. I changed point to a templated
tuple and declared the terminals x and y with
proto::_ template arguments. Here is the complete program :
#include <cassert>
#include
#include <iostream>
namespace proto = boost::proto;
template
struct tuple {
X x;
Y y;
};
template
struct tuple_types {
typedef X tuple::* X_type;
typedef Y tuple::* Y_type;
};
//Does not work
// proto::terminal::X_type>::type x
// = {&tuple::x};
// proto::terminal::Y_type>::type y
// = {&tuple::y};
proto::terminal::X_type>::type x
= {&tuple::x};
proto::terminal::Y_type>::type y
= {&tuple::y};
struct arg_ {};
proto::terminal::type arg = {{}};
struct micro_lambda
: proto::or_<
proto::when<
proto::terminal
, proto::_state
, proto::otherwise<
proto::_default
{} eval;
using namespace std;
int main()
{
tuple t;
t.x = 1;
t.y = 41.f;
cout << eval(arg->*x + arg->*y, t) << endl;
}
When I declare x and y like shown in the commented out part, I get
compile errors. What am I doing wrong there? Do I need extra grammar
rules to match the member pointers of a templated class?
Manjunath