]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
8 | #if !BOOST_PHOENIX_IS_ITERATING | |
9 | ||
10 | #include <boost/phoenix/core/limits.hpp> | |
11 | #include <boost/phoenix/support/iterate.hpp> | |
12 | ||
13 | namespace boost { namespace phoenix { namespace detail | |
14 | { | |
15 | template <int N, typename Dummy = void> | |
16 | struct function_ptr_impl | |
17 | { | |
18 | template <typename RT, typename FP> | |
19 | struct impl; | |
20 | }; | |
21 | ||
22 | template <int N, typename RT, typename FP> | |
23 | struct function_ptr : function_ptr_impl<N>::template impl<RT, FP> | |
24 | { | |
25 | typedef typename function_ptr_impl<N>::template impl<RT, FP> base; | |
26 | ||
27 | function_ptr(FP fp_) | |
28 | : base(fp_) {} | |
29 | ||
30 | using base::fp; | |
31 | ||
32 | bool operator==(function_ptr const & rhs) const | |
33 | { | |
34 | return fp == rhs.fp; | |
35 | } | |
36 | ||
37 | template <int M, typename RhsRT, typename RhsFP> | |
38 | bool operator==(function_ptr<M, RhsRT, RhsFP> const & /*rhs*/) const | |
39 | { | |
40 | return false; | |
41 | } | |
42 | ||
43 | }; | |
44 | ||
45 | template <typename Dummy> | |
46 | struct function_ptr_impl<0, Dummy> | |
47 | { | |
48 | template <typename RT, typename FP> | |
49 | struct impl | |
50 | { | |
51 | typedef RT result_type; | |
52 | ||
53 | impl(FP fp_) | |
54 | : fp(fp_) {} | |
55 | ||
56 | RT operator()() const | |
57 | { | |
58 | return fp(); | |
59 | } | |
60 | ||
61 | FP fp; | |
62 | }; | |
63 | }; | |
64 | ||
65 | template <typename Dummy> | |
66 | struct function_ptr_impl<1, Dummy> | |
67 | { | |
68 | template <typename RT, typename FP> | |
69 | struct impl | |
70 | { | |
71 | typedef RT result_type; | |
72 | ||
73 | impl(FP fp_) | |
74 | : fp(fp_) {} | |
75 | ||
76 | template <typename A> | |
77 | RT operator()(A &a) const | |
78 | { | |
79 | return fp(a); | |
80 | } | |
81 | ||
82 | FP fp; | |
83 | }; | |
84 | }; | |
85 | ||
86 | #if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES) | |
87 | #include <boost/phoenix/bind/detail/cpp03/preprocessed/function_ptr.hpp> | |
88 | #else | |
89 | ||
90 | #if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES) | |
91 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/function_ptr_" BOOST_PHOENIX_LIMIT_STR ".hpp") | |
92 | #endif | |
93 | ||
94 | /*============================================================================= | |
95 | Copyright (c) 2001-2007 Joel de Guzman | |
96 | ||
97 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
98 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
99 | ==============================================================================*/ | |
100 | ||
101 | #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES) | |
102 | #pragma wave option(preserve: 1) | |
103 | #endif | |
104 | ||
105 | #define BOOST_PHOENIX_ITERATION_PARAMS \ | |
106 | (3, (2, BOOST_PHOENIX_COMPOSITE_LIMIT, \ | |
107 | <boost/phoenix/bind/detail/cpp03/function_ptr.hpp>)) | |
108 | #include BOOST_PHOENIX_ITERATE() | |
109 | ||
110 | #if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES) | |
111 | #pragma wave option(output: null) | |
112 | #endif | |
113 | ||
114 | #endif | |
115 | ||
116 | }}} // namespace boost::phoenix::detail | |
117 | ||
118 | /////////////////////////////////////////////////////////////////////////////// | |
119 | // | |
120 | // Preprocessor vertical repetition code | |
121 | // | |
122 | /////////////////////////////////////////////////////////////////////////////// | |
123 | #else // defined(BOOST_PP_IS_ITERATING) | |
124 | ||
125 | template <typename Dummy> | |
126 | struct function_ptr_impl<BOOST_PHOENIX_ITERATION, Dummy> | |
127 | { | |
128 | template <typename RT, typename FP> | |
129 | struct impl | |
130 | { | |
131 | typedef RT result_type; | |
132 | ||
133 | impl(FP fp_) | |
134 | : fp(fp_) {} | |
135 | ||
136 | template <BOOST_PHOENIX_typename_A> | |
137 | RT operator()(BOOST_PHOENIX_A_ref_a) const | |
138 | { | |
139 | return fp(BOOST_PHOENIX_a); | |
140 | } | |
141 | ||
142 | FP fp; | |
143 | }; | |
144 | }; | |
145 | ||
146 | #endif // defined(BOOST_PP_IS_ITERATING) |