1 /*==============================================================================
2 Copyright (c) 2005-2010 Joel de Guzman
3 Copyright (c) 2010 Thomas Heller
4 Copyright (c) 2015 John Fletcher
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #ifndef BOOST_PHOENIX_FUNCTION_ADAPT_FUNCTION_HPP
10 #define BOOST_PHOENIX_FUNCTION_ADAPT_FUNCTION_HPP
12 #include <boost/phoenix/core/limits.hpp>
13 #include <boost/phoenix/core/detail/function_eval.hpp>
14 #include <boost/preprocessor/repetition/repeat.hpp>
16 #define BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(RESULT, NAME, FUNC) \
19 struct BOOST_PP_CAT(NAME, _impl_nullary) \
21 typedef RESULT result_type; \
32 boost::phoenix::detail::expression::function_eval< \
33 detail0:: BOOST_PP_CAT(NAME, _impl_nullary) \
37 return boost::phoenix::detail::expression:: \
38 function_eval<detail0:: BOOST_PP_CAT(NAME, _impl_nullary)> \
39 ::make(detail0:: BOOST_PP_CAT(NAME, _impl_nullary)()); \
43 #define BOOST_PHOENIX_ADAPT_FUNCTION(RESULT, NAME, FUNC, N) \
46 struct BOOST_PP_CAT(BOOST_PP_CAT(NAME, _impl_), N) \
48 template <typename Sig> \
51 template <typename This, BOOST_PHOENIX_typename_A(N)> \
52 struct result<This(BOOST_PHOENIX_A(N))> \
53 {typedef RESULT type;}; \
55 template <BOOST_PHOENIX_typename_A(N)> \
57 operator()(BOOST_PHOENIX_A_ref_a(N)) const \
59 return FUNC(BOOST_PHOENIX_a(N)); \
64 template <BOOST_PHOENIX_typename_A(N)> \
67 boost::phoenix::detail::expression::function_eval< \
68 detail1:: BOOST_PP_CAT(BOOST_PP_CAT(NAME, _impl_), N) \
69 , BOOST_PHOENIX_A(N)>::type const \
70 NAME(BOOST_PHOENIX_A_const_ref_a(N)) \
72 return boost::phoenix::detail::expression:: \
74 detail1:: BOOST_PP_CAT(BOOST_PP_CAT(NAME, _impl_), N) \
75 , BOOST_PHOENIX_A(N) \
77 detail1:: BOOST_PP_CAT(BOOST_PP_CAT(NAME, _impl_), N)() \
78 , BOOST_PHOENIX_a(N) \
83 #define BOOST_PHOENIX_ADAPT_FUNCTION_VARARG(RESULT, NAME, FUNC) \
84 BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(NAME, FUNC) \
85 BOOST_PP_REPEAT_FROM_TO( \
87 , BOOST_PHOENIX_LIMIT \
88 , BOOST_PHOENIX_ADAPT_FUNCTION_VARARG_R \
89 , (RESULT, NAME, FUNC) \
93 #define BOOST_PHOENIX_ADAPT_FUNCTION_VARARG_R(Z, N, D) \
94 BOOST_PHOENIX_ADAPT_FUNCTION( \
95 BOOST_PP_TUPLE_ELEM(3, 0, D) \
96 , BOOST_PP_TUPLE_ELEM(3, 1, D) \
97 , BOOST_PP_TUPLE_ELEM(3, 2, D) \