#include #include using namespace std; namespace proto = boost::proto; namespace mpl = boost::mpl; template struct expr_wrapper; struct arg_tag {}; struct wrapper_domain : proto::domain > {}; template struct arg : proto::or_ > > {}; template struct readonly : proto::callable { typedef const T& result_type; }; template struct readwrite : proto::callable { typedef T& result_type; }; template struct argtype : proto::or_< proto::when, proto::_>, readwrite()> , proto::otherwise()> > {}; namespace boost { namespace proto { template struct is_callable< readonly > : mpl::true_ {}; template struct is_callable< readwrite > : mpl::true_ {}; } } template struct expr_wrapper { BOOST_PROTO_BASIC_EXTENDS(Expr, expr_wrapper, wrapper_domain) BOOST_PROTO_EXTENDS_ASSIGN() BOOST_PROTO_EXTENDS_SUBSCRIPT() template struct atype : boost::result_of(const Expr&)> {}; typedef void result_type; template result_type operator()(typename boost::result_of(const Expr &)>::type arg0) const { cout << "arg0 " << arg0 << "\n"; } }; expr_wrapper >::type> const _1 = {{{}}}; expr_wrapper >::type> const _2 = {{{}}}; int main() { int i = 42; (_1)(i); return 0; }