/*============================================================================== Copyright (c) 2005-2010 Joel de Guzman Copyright (c) 2011 Thomas Heller Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include namespace phoenix = boost::phoenix; namespace proto = boost::proto; // define the expression namespace expression { template struct add : phoenix::expr {}; } // extend the grammar, to recognice the expression namespace boost { namespace phoenix { template <> struct meta_grammar::case_ : enable_rule< ::expression::add< meta_grammar , meta_grammar > > {}; }} // build a generator template typename expression::add::type add(Lhs const & lhs, Rhs const & rhs) { return expression::add::make(lhs, rhs); } #include #include int main() { add(6, 5); proto::display_expr(add(6, 5)); std::cout << add(5, 6)() << "\n"; }