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