Imported Upstream version 1.49.0
[platform/upstream/boost.git] / boost / phoenix / core / detail / phx2_result.hpp
1 /*=============================================================================
2     Copyright (c) 2011 Thomas Heller
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 #if !BOOST_PHOENIX_IS_ITERATING
8 #ifndef BOOST_PHOENIX_CORE_DETAIL_PHX2_RESULT_HPP
9 #define BOOST_PHOENIX_CORE_DETAIL_PHX2_RESULT_HPP
10 #include <boost/phoenix/core/limits.hpp>
11 #include <boost/phoenix/support/iterate.hpp>
12 #include <boost/mpl/has_xxx.hpp>
13
14 namespace boost { namespace phoenix {
15     namespace detail
16     {
17         BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
18
19         template <typename Result>
20         struct has_phx2_result_impl
21         {
22             typedef char yes;
23             typedef char (&no)[2];
24
25             template <typename A>
26             static yes check(typename A::type *);
27             
28             
29             template <typename A>
30             static no check(...);
31
32             static bool const value = (sizeof(yes) == sizeof(check<Result>(0)));
33             typedef boost::mpl::bool_<value> type;
34         };
35
36         template <typename F, BOOST_PHOENIX_typename_A_void(BOOST_PP_DEC(BOOST_PHOENIX_COMPOSITE_LIMIT)), typename Dummy = void>
37         struct has_phx2_result
38             : mpl::false_
39         {};
40
41         template <typename F, BOOST_PHOENIX_typename_A_void(BOOST_PP_DEC(BOOST_PHOENIX_COMPOSITE_LIMIT)), typename Dummy = void>
42         struct phx2_result;
43 #if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES)
44 #include <boost/phoenix/core/detail/preprocessed/phx2_result.hpp>
45 #else
46 #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
47 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/phx2_result_" BOOST_PHOENIX_LIMIT_STR ".hpp")
48 #endif
49 /*=============================================================================
50     Copyright (c) 2011 Thomas Heller
51
52     Distributed under the Boost Software License, Version 1.0. (See accompanying
53     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
54 ==============================================================================*/
55 #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
56 #pragma wave option(preserve: 1)
57 #endif
58
59
60         #define BOOST_PHOENIX_ITERATION_PARAMS                                  \
61             (3, (1, BOOST_PP_DEC(BOOST_PHOENIX_COMPOSITE_LIMIT),                \
62             <boost/phoenix/core/detail/phx2_result.hpp>))
63 #include BOOST_PHOENIX_ITERATE()
64
65 #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
66 #pragma wave option(output: null)
67 #endif
68
69 #endif
70     }
71 }}
72
73 #endif
74
75 #else
76
77         template <typename F, BOOST_PHOENIX_typename_A>
78         struct has_phx2_result<F, BOOST_PHOENIX_A>
79             : mpl::eval_if<
80                 has_result_type<F>
81               , mpl::false_
82               , has_phx2_result_impl<typename F::template result<F(BOOST_PHOENIX_A)> >
83             >::type
84         {};
85
86
87         template <typename F, BOOST_PHOENIX_typename_A>
88         struct phx2_result<F, BOOST_PHOENIX_A>
89         {
90             typedef typename F::template result<BOOST_PHOENIX_A>::type type;
91         };
92         
93         template <typename F, BOOST_PHOENIX_typename_A>
94         struct phx2_result<F, BOOST_PHOENIX_A_ref>
95         {
96             typedef typename F::template result<BOOST_PHOENIX_A>::type type;
97         };
98         
99         template <typename F, BOOST_PHOENIX_typename_A>
100         struct phx2_result<F, BOOST_PHOENIX_A_const_ref>
101         {
102             typedef typename F::template result<BOOST_PHOENIX_A>::type type;
103         };
104
105 #endif