@@ -74,10 +74,10 @@ namespace details
7474 {
7575 private:
7676 typedef void (generic_class::*generic_mem_fun)();
77+ typedef void (*generic_mem_ptr)();
78+
7779 generic_class *pmem;
7880 generic_mem_fun _pfunc;
79-
80- typedef void (*generic_mem_ptr)();
8181 generic_mem_ptr _spfunc;
8282
8383 public:
@@ -93,81 +93,33 @@ namespace details
9393 }
9494
9595 template <typename X, typename Y>
96- inline void bind (X* pmem, Y fun)
96+ binder (X* pmem, Y fun):
97+ pmem (converter<sizeof (fun)>::convert(pmem, fun, _pfunc)),
98+ _spfunc (0 )
9799 {
98- this ->pmem =
99- converter<sizeof (fun)>::convert (pmem, fun, _pfunc);
100- _spfunc = 0 ;
101100 }
102- template < class DC , class parent_invoker >
103- inline void bind_static (DC *pp,
104- parent_invoker invoker,
105- static_function fun
106- )
101+
102+ template < class DC , class parent_invoker >
103+ binder (DC* pp, parent_invoker invoker, static_function fun):
104+ pmem(converter< sizeof (invoker)>::convert(pp, invoker, _pfunc)),
105+ _spfunc( reinterpret_cast <generic_mem_ptr>(fun) )
107106 {
108- if (fun==0 )
109- _pfunc=0 ;
110- else
111- bind (pp, invoker);
112- _spfunc = reinterpret_cast <generic_mem_ptr>(fun);
113107 }
108+
114109 inline generic_class* exec () const
115110 {
116111 return pmem;
117112 }
118113 inline generic_mem get_mem_ptr () const
119114 {
120- return reinterpret_cast <generic_mem>(_pfunc);
115+ return reinterpret_cast <const generic_mem>(_pfunc);
121116 }
122117 inline void_static_function get_static_func () const
123118 {
124119 return reinterpret_cast <void_static_function>(_spfunc);
125120 }
126121 };
127122
128- template <typename RET_TYPE=void >
129- class functor_zero
130- {
131- private:
132- typedef RET_TYPE (*static_function)();
133- typedef RET_TYPE (*void_static_function)();
134- typedef RET_TYPE (generic_class::*generic_mem)();
135- typedef binder<generic_mem,
136- static_function, void_static_function> binder_type;
137- binder_type _binder;
138-
139- RET_TYPE exec_static () const
140- {
141- return (*(_binder.get_static_func ()))();
142- }
143- public:
144- typedef functor_zero type;
145- functor_zero () { }
146-
147- template <typename X, typename Y>
148- functor_zero (Y* pmem, RET_TYPE(X::*func)() )
149- {
150- _binder.bind (reinterpret_cast <X*>(pmem), func);
151- }
152- functor_zero (RET_TYPE(*func)() )
153- {
154- bind (func);
155- }
156- template < class X , class Y >
157- inline void bind (Y* pmem, RET_TYPE(X::*func)())
158- {
159- _binder.bind (reinterpret_cast <X*>(pmem), func);
160- }
161- inline void bind (RET_TYPE(*func)())
162- {
163- _binder.bind_static (this , &functor_zero::exec_static, func);
164- }
165- RET_TYPE operator () () const
166- {
167- return (_binder.exec ()->*(_binder.get_mem_ptr ()))();
168- }
169- };
170-
171123 template <typename PAR1, typename RET_TYPE=void >
172124 class functor_one
173125 {
@@ -183,28 +135,26 @@ namespace details
183135 {
184136 return (*(_binder.get_static_func ()))(p1);
185137 }
138+
139+ functor_one& operator =(const functor_one&)
140+ {
141+ return *this ;
142+ }
186143 public:
187144 typedef functor_one type;
188145 functor_one () { }
189146
190147 template <typename X, typename Y>
191- functor_one (Y* pmem, RET_TYPE(X::*func)(PAR1 p1) )
148+ functor_one (Y* pmem, RET_TYPE(X::*func)(PAR1 p1) ):
149+ _binder (reinterpret_cast <X*>(pmem), func)
192150 {
193- _binder.bind (reinterpret_cast <X*>(pmem), func);
194151 }
195- functor_one (RET_TYPE(*func)(PAR1 p1) )
196- {
197- bind (func);
198- }
199- template < class X , class Y >
200- inline void bind (Y* pmem, RET_TYPE(X::*func)(PAR1 p1))
201- {
202- _binder.bind (reinterpret_cast <X*>(pmem), func);
203- }
204- inline void bind (RET_TYPE(*func)(PAR1 P1))
152+
153+ functor_one (RET_TYPE(*func)(PAR1 p1) ):
154+ _binder (this , &functor_one::exec_static, func)
205155 {
206- _binder.bind_static (this , &functor_one::exec_static, func);
207156 }
157+
208158 RET_TYPE operator () (PAR1 p1) const
209159 {
210160 return (_binder.exec ()->*(_binder.get_mem_ptr ()))(p1);
@@ -241,142 +191,20 @@ namespace details
241191 }
242192
243193 template <typename X, typename Y>
244- functor_two (Y* pmem, RET_TYPE(X::*func)(PAR1 p1, PAR2 p2) )
194+ functor_two (Y* pmem, RET_TYPE(X::*func)(PAR1 p1, PAR2 p2) ):
195+ _binder (reinterpret_cast <X*>(pmem), func)
245196 {
246- _binder.bind (reinterpret_cast <X*>(pmem), func);
247197 }
248- functor_two (RET_TYPE(*func)(PAR1 p1, PAR2 p2) )
198+ functor_two (RET_TYPE(*func)(PAR1 p1, PAR2 p2) ):
199+ _binder (this , &functor_two::exec_static, func)
249200 {
250- bind (func);
251- }
252- template < class X , class Y >
253- inline void bind (Y* pmem, RET_TYPE(X::*func)(PAR1 p1, PAR2 p2))
254- {
255- _binder.bind (reinterpret_cast <X*>(pmem), func);
256- }
257- inline void bind (RET_TYPE(*func)(PAR1 P1, PAR2 p2))
258- {
259- _binder.bind_static (this , &functor_two::exec_static, func);
260201 }
202+
261203 RET_TYPE operator () (PAR1 p1, PAR2 p2) const
262204 {
263205 return (_binder.exec ()->*(_binder.get_mem_ptr ()))(p1, p2);
264206 }
265207 };
266-
267- template <typename PAR1,
268- typename PAR2, typename PAR3, typename RET_TYPE=void >
269- class functor_three
270- {
271- private:
272- typedef RET_TYPE (*static_function)(PAR1 p1, PAR2 p2, PAR3 p3);
273-
274- typedef RET_TYPE
275- (*void_static_function)(PAR1 p1, PAR2 p2, PAR3 p3);
276-
277- typedef RET_TYPE
278- (generic_class::*generic_mem)(PAR1 p1, PAR2 p2, PAR3 p3);
279-
280- typedef binder<
281- generic_mem, static_function, void_static_function
282- > binder_type;
283-
284- binder_type _binder;
285-
286- RET_TYPE exec_static (PAR1 p1, PAR2 p2, PAR3 p3) const
287- {
288- return (*(_binder.get_static_func ()))(p1, p2, p3);
289- }
290- public:
291- typedef functor_three type;
292- functor_three () { }
293-
294- template <typename X, typename Y>
295- functor_three (Y* pmem, RET_TYPE(X::*func)(
296- PAR1 p1, PAR2 p2, PAR3 p3)
297- )
298- {
299- _binder.bind (reinterpret_cast <X*>(pmem), func);
300- }
301- functor_three (RET_TYPE(*func)(PAR1 p1, PAR2 p2, PAR3 p3) )
302- {
303- bind (func);
304- }
305- template < class X , class Y >
306- inline void bind (Y* pmem,
307- RET_TYPE (X::*func)(PAR1 p1, PAR2 p2, PAR3 p3)
308- )
309- {
310- _binder.bind (reinterpret_cast <X*>(pmem), func);
311- }
312- inline void bind (RET_TYPE(*func)(PAR1 P1, PAR2 p2, PAR3 p3))
313- {
314- _binder.bind_static (this , &functor_three::exec_static,func);
315- }
316- RET_TYPE operator () (PAR1 p1, PAR2 p2, PAR3 p3) const
317- {
318- return (_binder.exec ()->*(_binder.get_mem_ptr ()))(p1,p2,p3);
319- }
320- };
321-
322- template <typename PAR1,
323- typename PAR2, typename PAR3, typename PAR4, typename RET_TYPE=void >
324- class functor_four
325- {
326- private:
327- typedef RET_TYPE
328- (*static_function)(PAR1 p1, PAR2 p2, PAR3 p3, PAR4 p4);
329-
330- typedef RET_TYPE
331- (*void_static_function)(PAR1 p1, PAR2 p2, PAR3 p3, PAR4 p4);
332-
333- typedef RET_TYPE (generic_class::*generic_mem)
334- (PAR1 p1, PAR2 p2, PAR3 p3, PAR4 p4);
335-
336- typedef binder<
337- generic_mem, static_function, void_static_function
338- > binder_type;
339-
340- binder_type _binder;
341-
342- RET_TYPE exec_static (PAR1 p1, PAR2 p2, PAR3 p3, PAR4 p4) const
343- {
344- return (*(_binder.get_static_func ()))(p1, p2, p3, p4);
345- }
346- public:
347- typedef functor_four type;
348- functor_four () { }
349-
350- template <typename X, typename Y>
351- functor_four (Y* pmem,
352- RET_TYPE (X::*func)(PAR1 p1, PAR2 p2, PAR3 p3, PAR4 p4)
353- )
354- {
355- _binder.bind (reinterpret_cast <X*>(pmem), func);
356- }
357- functor_four (RET_TYPE(*func)(PAR1 p1,PAR2 p2,PAR3 p3,PAR4 p4))
358- {
359- bind (func);
360- }
361- template < class X , class Y >
362- inline void bind (Y* pmem,
363- RET_TYPE (X::*func)(PAR1 p1, PAR2 p2, PAR3 p3, PAR4 p4)
364- )
365- {
366- _binder.bind (reinterpret_cast <X*>(pmem), func);
367- }
368- inline void bind (
369- RET_TYPE (*func)(PAR1 P1, PAR2 p2, PAR3 p3, PAR4 p4)
370- )
371- {
372- _binder.bind_static (this , &functor_four::exec_static, func);
373- }
374- RET_TYPE operator () (PAR1 p1, PAR2 p2, PAR3 p3, PAR4 p4) const
375- {
376- return
377- (_binder.exec ()->*(_binder.get_mem_ptr ()))(p1,p2,p3,p4);
378- }
379- };
380208 }
381209}}
382210
0 commit comments