[proto] grammar to match operator in expression

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[proto] grammar to match operator in expression

Igor R.
Hi,

Why the following grammar doesn't match dereference, and what's the
correct way to do this?

Thanks!

//////////////////
#include <iostream>
#include <boost/proto/proto.hpp>

namespace proto = boost::proto;
using proto::_;

struct has_deref : proto::or_<
    proto::dereference<_>,
    proto::nary_expr<_, proto::vararg<has_deref>>
    >
{};

template<class Expr>
void test_expr(const Expr &e)
{
    proto::display_expr(e);
    std::cout << "matches? " << std::boolalpha << proto::matches<Expr,
has_deref>::value << std::endl;
}

int main()
{
    test_expr(proto::lit(1) + *proto::lit(2));
}
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users