• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef BOOST_PHOENIX_CORE_DETAIL_PHX2_RESULT_HPP
8 #define BOOST_PHOENIX_CORE_DETAIL_PHX2_RESULT_HPP
9 #include <boost/phoenix/core/limits.hpp>
10 #include <boost/phoenix/support/iterate.hpp>
11 #include <boost/mpl/has_xxx.hpp>
12 #include <boost/mpl/bool.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             template <typename A>
29             static no check_(...);
30 
31             static bool const value = (sizeof(yes) == sizeof(check_<Result>(0)));
32             typedef boost::mpl::bool_<value> type;
33         };
34 
35 #ifdef BOOST_PHOENIX_NO_VARIADIC_PHX2_RESULT
36         #include <boost/phoenix/core/detail/cpp03/phx2_result.hpp>
37 #else
38         template <typename F, typename... A>
39         struct has_phx2_result
40             : mpl::eval_if<
41                 has_result_type<F>
42               , mpl::false_
43               , has_phx2_result_impl<typename F::template result<F(A...)> >
44             >::type
45         {};
46 
47         template <typename F, typename... A>
48         struct phx2_result
49         {
50             typedef typename F::template result<A...>::type type;
51         };
52 
53         template <typename F, typename... A>
54         struct phx2_result<F, A &...>
55         {
56             typedef typename F::template result<A...>::type type;
57         };
58 
59         template <typename F, typename... A>
60         struct phx2_result<F, A const &...>
61         {
62             typedef typename F::template result<A...>::type type;
63         };
64 #endif
65     }
66 }}
67 
68 #endif
69 
70