1+ #include < attwoodn/expression_tree.hpp>
2+ #include < iostream>
3+ #include < cassert>
4+
5+ using namespace attwoodn ::expression_tree;
6+
7+ struct test_fixture {
8+ std::string some_string;
9+ };
10+
11+ template <class T > struct type_id {typedef T type;};
12+
13+ // template<typename Obj, typename CompValue, typename Op = typename type_id<bool (*)(CompValue*, CompValue*)>::type>
14+ // node::expression_tree_leaf_node<Obj, Op, CompValue>* make_leaf_node( CompValue Obj::* member_var, Op op, CompValue comp_value ) {
15+ // return new node::expression_tree_leaf_node<Obj, Op, CompValue>( member_var, op, comp_value );
16+ // }
17+
18+ template <typename Obj, typename CompValue, typename Op = typename type_id<bool (*)(CompValue, CompValue)>::type>
19+ node::expression_tree_leaf_node<Obj, Op, CompValue>* make_leaf_node ( CompValue Obj::* member_var, Op op, CompValue comp_value ) {
20+ return new node::expression_tree_leaf_node<Obj, Op, CompValue>( member_var, op, comp_value );
21+ }
22+
23+ int main (int argc, char ** argv) {
24+ test_fixture fixture;
25+ fixture.some_string = " hello world!" ;
26+
27+ auto node = make_leaf_node (&test_fixture::some_string, &op::equals, std::string (" hello world!" ));
28+ assert (node->evaluate (fixture));
29+
30+ fixture.some_string = " hey, world!" ;
31+ assert (!node->evaluate (fixture));
32+
33+ return EXIT_SUCCESS;
34+ }
0 commit comments