/*============================================================================== Copyright (c) 2005-2010 Joel de Guzman Copyright (c) 2010 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) ==============================================================================*/ #ifndef BOOST_PHOENIX_DEFINE_OPERATOR_HPP #define BOOST_PHOENIX_DEFINE_OPERATOR_HPP #include #include #define BOOST_PHOENIX_UNARY_EXPRESSION(__, ___, name) \ template \ struct name \ : expr \ {}; \ /**/ #define BOOST_PHOENIX_UNARY_RULE(__, ___, name) \ struct name \ : expression::name \ {}; \ /**/ #define BOOST_PHOENIX_UNARY_FUNCTIONAL(__, ___, name) \ namespace functional \ { \ typedef \ proto::functional::make_expr \ BOOST_PP_CAT(make_, name); \ } \ namespace result_of \ { \ template \ struct BOOST_PP_CAT(make_, name) \ : boost::result_of< \ functional:: BOOST_PP_CAT(make_, name)( \ Operand \ ) \ > \ {}; \ } \ template \ typename result_of::BOOST_PP_CAT(make_, name)::type \ inline BOOST_PP_CAT(make_, name)(Operand const & operand) \ { \ return functional::BOOST_PP_CAT(make_, name)()(operand); \ } \ /**/ #define BOOST_PHOENIX_BINARY_EXPRESSION(__, ___, name) \ template \ struct name \ : expr \ {}; \ /**/ #define BOOST_PHOENIX_BINARY_RULE(__, ___, name) \ struct name \ : expression::name \ {}; \ /**/ #define BOOST_PHOENIX_BINARY_FUNCTIONAL(__, ___, name) \ namespace functional \ { \ typedef \ proto::functional::make_expr \ BOOST_PP_CAT(make_, name); \ } \ namespace result_of \ { \ template \ struct BOOST_PP_CAT(make_, name) \ : boost::result_of< \ functional:: BOOST_PP_CAT(make_, name)( \ Lhs, Rhs \ ) \ > \ {}; \ } \ template \ typename result_of::BOOST_PP_CAT(make_, name)::type \ inline BOOST_PP_CAT(make_, name)(Lhs const & lhs, Rhs const & rhs) \ { \ return functional::BOOST_PP_CAT(make_, name)()(lhs, rhs); \ } \ /**/ #define BOOST_PHOENIX_GRAMMAR(_, __, name) \ template \ struct meta_grammar::case_ \ : enable_rule \ {}; \ /**/ #define BOOST_PHOENIX_UNARY_OPERATORS(ops) \ namespace expression { \ BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_EXPRESSION, _, ops) \ } \ namespace rule { \ BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_RULE, _, ops) \ } \ BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_GRAMMAR, _, ops) \ BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_FUNCTIONAL, _, ops) \ /**/ #define BOOST_PHOENIX_BINARY_OPERATORS(ops) \ namespace expression { \ BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_EXPRESSION, _, ops) \ } \ namespace rule { \ BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_RULE, _, ops) \ } \ BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_GRAMMAR, _, ops) \ BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_FUNCTIONAL, _, ops) \ /**/ #endif