comparison DEPENDENCIES/generic/include/boost/phoenix/bind/detail/member_function_ptr.hpp @ 16:2665513ce2d3

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