Imported Upstream version 1.51.0
[platform/upstream/boost.git] / boost / spirit / home / phoenix / operator / detail / binary_eval.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2007 Joel de Guzman
3
4     Distributed under the Boost Software License, Version 1.0. (See accompanying 
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #ifndef PHOENIX_OPERATOR_DETAIL_BINARY_EVAL_HPP
8 #define PHOENIX_OPERATOR_DETAIL_BINARY_EVAL_HPP
9
10 #include <boost/mpl/or.hpp>
11 #include <boost/mpl/eval_if.hpp>
12 #include <boost/mpl/identity.hpp>
13 #include <boost/type_traits/is_same.hpp>
14 #include <boost/spirit/home/phoenix/core/compose.hpp>
15
16 #define PHOENIX_BINARY_EVAL(eval_name, op_result, expr)                         \
17     struct eval_name                                                            \
18     {                                                                           \
19         template <typename Env, typename A0, typename A1>                       \
20         struct result                                                            \
21         {                                                                       \
22             typedef typename A0::template result<Env>::type x_type;              \
23             typedef typename A1::template result<Env>::type y_type;              \
24                                                                                 \
25             typedef typename                                                    \
26                 mpl::eval_if<                                                   \
27                     mpl::or_<is_actor<x_type>, is_actor<y_type> >               \
28                   , re_curry<eval_name, x_type, y_type>                         \
29                   , op_result<x_type, y_type>                                   \
30                 >::type                                                         \
31             type;                                                               \
32         };                                                                      \
33                                                                                 \
34         template <typename RT, typename Env, typename A0, typename A1>          \
35         static RT                                                               \
36         eval(Env const& env, A0& a0, A1& a1)                                    \
37         {                                                                       \
38             return expr;                                                        \
39         }                                                                       \
40     };
41
42 #undef x
43 #undef y
44 #endif