//demonstrate mixing is grammars with transforms is //an instance of blob anti-pattern. // #include using namespace boost; //The following code is (essentially) from // _C++ Template Metaprogramming_ // section 2.2 "Metafunctions" // page 16. // template struct apply_fg_sep { template struct matches : UnaryOp1::template test {}; template typename UnaryOp2::template result::type transform(X x) { UnaryOp2 xfrm; return xfrm(x); } }; template struct apply_fg_blob { typedef typename Blob::unary_op1 unary_op1; template struct matches : unary_op1::template test {}; typedef typename Blob::unary_op2 unary_op2; template typename unary_op2::template result::type transform(X x) { typename Blob::unary_op2 xfrm; return xfrm(x); } }; struct grammar_always_true { template struct test : mpl::true_ {}; }; struct transform_ident { template struct result { typedef X type; }; template typename result::type operator()(X x) { return x; }; }; template struct blob { typedef UnaryOp1 unary_op1; typedef UnaryOp2 unary_op2; }; #include int main(void) { { std::cout<<"sep demo:\n"; typedef apply_fg_sep gram_xfrm; std::cout<::value<<"\n"; std::cout< > gram_xfrm; std::cout<::value<<"\n"; std::cout<