• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*==============================================================================
2     Copyright (c) 2005-2010 Joel de Guzman
3     Copyright (c) 2011 Thomas Heller
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #ifndef BOOST_PHOENIX_FUNCTION_ADAPT_CALLABLE_HPP
9 #define BOOST_PHOENIX_FUNCTION_ADAPT_CALLABLE_HPP
10 
11 #include <boost/phoenix/core/limits.hpp>
12 #include <boost/phoenix/core/detail/function_eval.hpp>
13 #include <boost/preprocessor/repetition/repeat.hpp>
14 
15 #define BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY(NAME, FUNC)                        \
16     inline                                                                      \
17     boost::phoenix::detail::expression::function_eval<FUNC>::type const         \
18     NAME()                                                                      \
19     {                                                                           \
20         return boost::phoenix::detail::expression::                             \
21                 function_eval<FUNC>::make(FUNC());                              \
22     }                                                                           \
23 /**/
24 
25 
26 #define BOOST_PHOENIX_ADAPT_CALLABLE(NAME, FUNC, N)                             \
27     template <BOOST_PHOENIX_typename_A(N)>                                      \
28     inline                                                                      \
29     typename                                                                    \
30         boost::phoenix::detail::expression::function_eval<                      \
31             FUNC                                                                \
32           , BOOST_PHOENIX_A(N)>::type const                                     \
33     NAME(BOOST_PHOENIX_A_const_ref_a(N))                                        \
34     {                                                                           \
35         return boost::phoenix::detail::expression::                             \
36             function_eval<FUNC, BOOST_PHOENIX_A(N)>::                           \
37                 make(FUNC(), BOOST_PHOENIX_a(N));                               \
38     }                                                                           \
39 /**/
40 
41 
42 #define BOOST_PHOENIX_ADAPT_CALLABLE_VARARG(NAME, FUNC)                         \
43     BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY(NAME, FUNC)                            \
44     BOOST_PP_REPEAT_FROM_TO(                                                    \
45         1                                                                       \
46       , BOOST_PHOENIX_LIMIT                                                     \
47       , BOOST_PHOENIX_ADAPT_CALLABLE_VARARG_R                                   \
48       , (NAME, FUNC)                                                            \
49     )                                                                           \
50 /**/
51 
52 #define BOOST_PHOENIX_ADAPT_CALLABLE_VARARG_R(Z, N, D)                          \
53     BOOST_PHOENIX_ADAPT_CALLABLE(                                               \
54         BOOST_PP_TUPLE_ELEM(2, 0, D)                                            \
55       , BOOST_PP_TUPLE_ELEM(2, 1, D)                                            \
56       , N                                                                       \
57     )                                                                           \
58 /**/
59 
60 #endif
61