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