// TestProto.cpp : Defines the entry point for the console application. // #include #include #include #include #include BOOST_MPL_HAS_XXX_TRAIT_DEF(type) using namespace std; namespace proto = boost::proto; namespace mpl = boost::mpl; struct state_tag{}; struct event_tag{}; struct action_tag{}; struct guard_tag{}; struct none{}; template struct Row { typedef T1 Source; typedef T2 Evt; typedef T3 Target; typedef T4 Action; typedef T5 Guard; }; template struct make_type { typedef TAG type; }; template struct make_type >::type> { typedef typename TAG::type type; }; template struct fusion_left_right { typedef Row type; }; template struct fusion_target_action_guard { typedef Row type; }; // row grammar struct BuildSourcePlusEvent : proto::when< proto::plus,proto::terminal >, Row(),make_type()>() > {}; struct BuildActionPlusGuard : proto::when< proto::mem_ptr,proto::terminal >, Row(),make_type()>() > {}; struct BuildTarget : proto::when< proto::terminal, Row()>() > {}; struct BuildRight : proto::or_< // after >>, if just state without guard/action proto::when< proto::terminal, Row(),none>() > // >> target / action , proto::when< proto::divides,proto::terminal >, Row(),make_type()>() > // >> target ->* guard , proto::when< proto::mem_ptr,proto::terminal >, Row(),none,make_type()>() > // >> target / action ->* guard , proto::when< proto::divides, fusion_target_action_guard()>, BuildActionPlusGuard(proto::_right)>() > > {}; struct BuildRow : proto::or_< proto::when< proto::equal_to, fusion_left_right() > , proto::nary_expr > > {}; template void print_row(Expr const& expr) { cout << "in print_row" << endl; cout << "matches:" << proto::matches::value << endl; typedef boost::result_of::type result_type; cout << "result_type" << endl; cout << typeid(result_type).name() << endl; cout << "end print_row" << endl; } struct s1{}; struct s2{}; struct e1: proto::terminal::type{}; template struct is_terminal : mpl::false_ {}; // OK, s1,s2,s3 are custom terminal types template<> struct is_terminal : mpl::true_ {}; template<> struct is_terminal : mpl::true_ {}; //BOOST_PROTO_DEFINE_OPERATORS(is_terminal, proto::default_domain) int main() { print_row( s1() + e1() == s2() ); return 0; }