#include #include #include #include #include namespace mpl = boost::mpl; namespace proto = boost::proto; namespace fusion = boost::fusion; using proto::_; struct my_grammar : proto::or_< proto::terminal< int >, proto::binary_expr<_, my_grammar, my_grammar> > {}; template struct my_expr; struct my_domain : proto::domain, my_grammar> {}; template struct my_expr : proto::extends, my_domain> { typedef proto::extends, my_domain> base_type; my_expr( Expr const & expr = Expr() ) : base_type( expr ) {} struct assign { typedef int result_type; template result_type operator()(const T& t, int offset) const { proto::value (const_cast(t)) = offset; return offset+sizeof (T); } }; template const my_expr& operator=(const E&) const { fusion::fold(proto::flatten (*this), 0, assign ()); return *this; } }; struct my_int : my_expr< proto::terminal< int >::type > { typedef my_expr< proto::terminal< int >::type > base_type; explicit my_int (int i = 0) : base_type (base_type::proto_base_expr::make (i)) {} operator int () { return proto::value (*this); } }; int main() { my_int i (1); my_int j (2); my_int k (3); (k,j) = (j,k); std::cout << j << std::endl << k << std::endl; return 0; } /// Local Variables: /// mode:c++ /// comment-column:60 /// fill-column:150 /// compile-command:"g++ -I. -I./boost -o testcase testcase.cpp" /// c-macro-cppflags:"-C -I. -I./boost" /// c-backslash-column:120 /// c-backslash-max-column:149 /// End: