Photon microGUI widgets library 0.6.0
delegate.h
1
2#ifndef DELEGATE_H
3#define DELEGATE_H
4#if _MSC_VER > 1000
5#pragma once
6#endif // _MSC_VER > 1000
7
8//wrapper for Fast Delegates of Don Clugston
9//adds some jucy functionality
10//now you could bind to some free functions that accept pointer to 'this' as first parameter (like member function but nah)
11
12/******************************************************************************************************************************/
13/* So you could now bind f.e. 'delegates::delegate<return_type, param_type1, param_type2>' to: */
14/* */
15/* 1) { return_type function(param_type1 param1, param_type2 param2); } */
16/* 2) { this_type pthis, return_type function(this_type param1, param_type1 param2, param_type2 param3); } */
17/* 3) { this_type pthis, return_type this_type::member_function(param_type1 param1, param_type2 param2); } */
18/* 4) { this_type pthis, return_type function(const this_type param1, param_type1 param2, param_type2 param3); } */
19/* 5) { const this_type pthis, return_type this_type::member_function const (param_type1 param1, param_type2 param2); } */
20/* */
21/******************************************************************************************************************************/
22
23#include "FastDelegate.h"
24
25#include <algorithm>
26#include <utility>
27#include <cstring>
28#include <cassert>
29
30namespace delegates
31{
32 namespace detail
33 {
34 typedef fastdelegate::detail::DefaultVoid DefaultVoid;
35
36 struct DelegateMementoHack :
37 public fastdelegate::DelegateMemento
38 {
39 static
40 void copy_pthis(fastdelegate::DelegateMemento &memento_to, const fastdelegate::DelegateMemento &memento_from)
41 {
42 memento_to.*(&DelegateMementoHack::m_pthis) = memento_from.*(&DelegateMementoHack::m_pthis);
43 }
44
45 static
46 bool is_equal_pFunction(const fastdelegate::DelegateMemento &memento1, const fastdelegate::DelegateMemento &memento2)
47 {
48 fastdelegate::DelegateMemento
49 lhs(memento1), rhs(memento2);
50 lhs.*(&DelegateMementoHack::m_pthis) = NULL;
51 rhs.*(&DelegateMementoHack::m_pthis) = NULL;
52 return lhs.IsEqual(rhs);
53 }
54
55 static
56 bool is_less_pFunction(const fastdelegate::DelegateMemento &memento1, const fastdelegate::DelegateMemento &memento2)
57 {
58 fastdelegate::DelegateMemento
59 lhs(memento1), rhs(memento2);
60 lhs.*(&DelegateMementoHack::m_pthis) = NULL;
61 rhs.*(&DelegateMementoHack::m_pthis) = NULL;
62 return lhs.IsLess(rhs);
63 }
64 };
65 }
66
67 template <
68 class ReturnT = detail::DefaultVoid,
69 class Param1T = detail::DefaultVoid,
70 class Param2T = detail::DefaultVoid,
71 class Param3T = detail::DefaultVoid,
72 class Param4T = detail::DefaultVoid,
73 class Param5T = detail::DefaultVoid,
74 class Param6T = detail::DefaultVoid,
75 class Param7T = detail::DefaultVoid,
76 class Param8T = detail::DefaultVoid,
77 class ParamUnusedT = detail::DefaultVoid
78 >
79 class delegate;
80
81 template<class ReturnT>
82 class delegate<ReturnT, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid> :
83 public fastdelegate::FastDelegate0<ReturnT>
84 {
85 typedef ReturnT(*free_function_like_member_t)(void* );
86
87 typedef ReturnT(delegate::* f_proxy_type)() const;
88
89 template<class Y>
90 inline
91 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*)) const
92 { return &delegate::f_proxy<Y>; }
93
94 template<class Y>
95 inline
96 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*)) const
97 { return &delegate::f_proxy_const<Y>; }
98
99 template<class Y>
100 inline
101 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*)) const
102 { return &delegate::f_proxy_const<Y>; }
103
104 public:
105 typedef fastdelegate::FastDelegate0< ReturnT > base_type;
106
107 typedef delegate type;
108
109 delegate()
110 : base_type(),
111 m_pthis(NULL),
112 m_free_func(NULL)
113 { }
114
115 template < class X, class Y >
116 delegate(Y * pthis,
117 ReturnT(X::* function_to_bind)( ))
118 : base_type(pthis, function_to_bind),
119 m_pthis(NULL),
120 m_free_func(NULL)
121 {
122 assert(NULL != pthis);
123 assert(NULL != function_to_bind);
124 }
125
126 template < class X, class Y >
127 delegate(const Y *pthis,
128 ReturnT(X::* function_to_bind)( ) const)
129 : base_type(pthis, function_to_bind),
130 m_pthis(NULL),
131 m_free_func(NULL)
132 {
133 assert(NULL != pthis);
134 assert(NULL != function_to_bind);
135 }
136
137 template < class Y >
138 delegate(Y *pthis,
139 ReturnT(*function_to_bind)(Y* ))
140 : base_type(this, get_proxy(pthis, function_to_bind)),
141 m_pthis(static_cast<void*>(pthis)),
142 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
143 { }
144
145 template < class Y >
146 delegate(Y *pthis,
147 ReturnT(*function_to_bind)(const Y* ))
148 : base_type(this, get_proxy(pthis, function_to_bind)),
149 m_pthis(static_cast<void*>(pthis)),
150 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
151 { }
152
153 template < class Y >
154 delegate(const Y *pthis,
155 ReturnT(*function_to_bind)(const Y*))
156 : base_type(this, get_proxy(pthis, function_to_bind)),
157 m_pthis(static_cast<void*>(pthis)),
158 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
159 { }
160
161
162 delegate(ReturnT(*function_to_bind)( ))
163 : base_type(function_to_bind),
164 m_pthis(NULL),
165 m_free_func(NULL)
166 {
167 assert(NULL != function_to_bind);
168 }
169
170 delegate(const delegate &other)
171 {
172 {
173 f_proxy_type proxy = &delegate::f_proxy<delegate>;
174 base_type::bind(this, proxy);
175 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
176 if(other.m_free_func)
177 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
178 base_type::SetMemento(tmp);
179 }
180 using namespace std;
181 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
182 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
183 }
184
185 void operator=(const delegate &other)
186 {
187 {
188 f_proxy_type proxy = &delegate::f_proxy<delegate>;
189 base_type::bind(this, proxy);
190 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
191 if(other.m_free_func)
192 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
193 base_type::SetMemento(tmp);
194 }
195 using namespace std;
196 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
197 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
198 }
199
200 bool operator==(const delegate &other) const
201 {
202 if(!m_free_func && !other.m_free_func)
203 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
204
205 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
206 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
207 else
208 return false;
209 }
210
211 bool operator!=(const delegate &other) const
212 {
213 return !(*this == other);
214 }
215
216 bool operator<(const delegate &other) const
217 {
218 if(!m_free_func && !other.m_free_func)
219 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
220 if(m_pthis != other.m_pthis)
221 return m_pthis < other.m_pthis;
222 if(m_free_func != other.m_free_func)
223 return m_free_func < other.m_free_func;
224 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
225 }
226
227 bool operator>(const delegate &other) const
228 {
229 if(!m_free_func && !other.m_free_func)
230 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
231 if(m_pthis != other.m_pthis)
232 return m_pthis > other.m_pthis;
233 if(m_free_func != other.m_free_func)
234 return m_free_func > other.m_free_func;
235 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
236 }
237
238 template < class Y >
239 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y* )) {
240 this->clear();
241 m_pthis = static_cast<void*>(pthis);
242 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
243 bind(this, get_proxy(pthis, function_to_bind));
244 }
245
246 template < class Y >
247 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y* )) {
248 this->clear();
249 m_pthis = static_cast<void*>(pthis);
250 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
251 bind(this, get_proxy(pthis, function_to_bind));
252 }
253
254 template < class Y >
255 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*)) {
256 this->clear();
257 m_pthis = static_cast<void*>(pthis);
258 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
259 bind(this, get_proxy(pthis, function_to_bind));
260 }
261
262 template < class X, class Y >
263 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)()) {
264 assert(NULL != pthis);
265 assert(NULL != function_to_bind);
266 m_pthis = NULL; m_free_func = NULL;
267 base_type::bind(pthis, function_to_bind);
268 }
269
270 template < class X, class Y >
271 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)() const) {
272 assert(NULL != pthis);
273 assert(NULL != function_to_bind);
274 m_pthis = NULL; m_free_func = NULL;
275 base_type::bind(pthis, function_to_bind);
276 }
277
278 inline void bind(ReturnT(*function_to_bind)()) {
279 assert(NULL != function_to_bind);
280 m_pthis = NULL; m_free_func = NULL;
281 base_type::bind(function_to_bind);
282 }
283
284 private:
285
286 void *m_pthis;
287 free_function_like_member_t m_free_func;
288
289 template< class Y >
290 ReturnT f_proxy() const
291 {
292 typedef ReturnT(*type_free_function_like_member_t)(Y* );
293
294 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis));
295 }
296
297 template< class Y >
298 ReturnT f_proxy_const() const
299 {
300 typedef ReturnT(*type_free_function_like_member_t)(const Y* );
301
302 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis));
303 }
304 };
305
306 template<class ReturnT, class Param1T>
307 class delegate<ReturnT, Param1T, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid> :
308 public fastdelegate::FastDelegate1<Param1T, ReturnT>
309 {
310 typedef ReturnT(*free_function_like_member_t)(void*, Param1T);
311
312 typedef ReturnT(delegate::* f_proxy_type)(Param1T) const;
313
314 template<class Y>
315 inline
316 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*, Param1T)) const
317 { return &delegate::f_proxy<Y>; }
318
319 template<class Y>
320 inline
321 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*, Param1T)) const
322 { return &delegate::f_proxy_const<Y>; }
323
324 template<class Y>
325 inline
326 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*, Param1T)) const
327 { return &delegate::f_proxy_const<Y>; }
328
329 public:
330 typedef fastdelegate::FastDelegate1<Param1T, ReturnT> base_type;
331
332 typedef delegate type;
333
334 delegate()
335 : base_type(),
336 m_pthis(NULL),
337 m_free_func(NULL)
338 { }
339
340 template < class X, class Y >
341 delegate(Y * pthis,
342 ReturnT(X::* function_to_bind)(Param1T))
343 : base_type(pthis, function_to_bind),
344 m_pthis(NULL),
345 m_free_func(NULL)
346 {
347 assert(NULL != pthis);
348 assert(NULL != function_to_bind);
349 }
350
351 template < class X, class Y >
352 delegate(const Y *pthis,
353 ReturnT(X::* function_to_bind)(Param1T) const)
354 : base_type(pthis, function_to_bind),
355 m_pthis(NULL),
356 m_free_func(NULL)
357 {
358 assert(NULL != pthis);
359 assert(NULL != function_to_bind);
360 }
361
362 template < class Y >
363 delegate(Y *pthis,
364 ReturnT(*function_to_bind)(Y*, Param1T))
365 : base_type(this, get_proxy(pthis, function_to_bind)),
366 m_pthis(static_cast<void*>(pthis)),
367 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
368 { }
369
370 template < class Y >
371 delegate(Y *pthis,
372 ReturnT(*function_to_bind)(const Y*, Param1T))
373 : base_type(this, get_proxy(pthis, function_to_bind)),
374 m_pthis(static_cast<void*>(pthis)),
375 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
376 { }
377
378 template < class Y >
379 delegate(const Y *pthis,
380 ReturnT(*function_to_bind)(const Y*, Param1T))
381 : base_type(this, get_proxy(pthis, function_to_bind)),
382 m_pthis(static_cast<void*>(pthis)),
383 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
384 { }
385
386
387 delegate(ReturnT(*function_to_bind)(Param1T))
388 : base_type(function_to_bind),
389 m_pthis(NULL),
390 m_free_func(NULL)
391 {
392 assert(NULL != function_to_bind);
393 }
394
395 delegate(const delegate &other)
396 {
397 {
398 f_proxy_type proxy = &delegate::f_proxy<delegate>;
399 base_type::bind(this, proxy);
400 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
401 if(other.m_free_func)
402 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
403 base_type::SetMemento(tmp);
404 }
405 using namespace std;
406 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
407 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
408 }
409
410 void operator=(const delegate &other)
411 {
412 {
413 f_proxy_type proxy = &delegate::f_proxy<delegate>;
414 base_type::bind(this, proxy);
415 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
416 if(other.m_free_func)
417 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
418 base_type::SetMemento(tmp);
419 }
420 using namespace std;
421 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
422 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
423 }
424
425 bool operator==(const delegate &other) const
426 {
427 if(!m_free_func && !other.m_free_func)
428 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
429
430 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
431 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
432 else
433 return false;
434 }
435
436 bool operator!=(const delegate &other) const
437 {
438 return !(*this == other);
439 }
440
441 bool operator<(const delegate &other) const
442 {
443 if(!m_free_func && !other.m_free_func)
444 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
445 if(m_pthis != other.m_pthis)
446 return m_pthis < other.m_pthis;
447 if(m_free_func != other.m_free_func)
448 return m_free_func < other.m_free_func;
449 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
450 }
451
452 bool operator>(const delegate &other) const
453 {
454 if(!m_free_func && !other.m_free_func)
455 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
456 if(m_pthis != other.m_pthis)
457 return m_pthis > other.m_pthis;
458 if(m_free_func != other.m_free_func)
459 return m_free_func > other.m_free_func;
460 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
461 }
462
463 template < class Y >
464 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y*, Param1T)) {
465 this->clear();
466 m_pthis = static_cast<void*>(pthis);
467 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
468 bind(this, get_proxy(pthis, function_to_bind));
469 }
470
471 template < class Y >
472 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T)) {
473 this->clear();
474 m_pthis = static_cast<void*>(pthis);
475 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
476 bind(this, get_proxy(pthis, function_to_bind));
477 }
478
479 template < class Y >
480 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T)) {
481 this->clear();
482 m_pthis = static_cast<void*>(pthis);
483 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
484 bind(this, get_proxy(pthis, function_to_bind));
485 }
486
487 template < class X, class Y >
488 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)(Param1T)) {
489 assert(NULL != pthis);
490 assert(NULL != function_to_bind);
491 m_pthis = NULL; m_free_func = NULL;
492 base_type::bind(pthis, function_to_bind);
493 }
494
495 template < class X, class Y >
496 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)(Param1T) const) {
497 assert(NULL != pthis);
498 assert(NULL != function_to_bind);
499 m_pthis = NULL; m_free_func = NULL;
500 base_type::bind(pthis, function_to_bind);
501 }
502
503 inline void bind(ReturnT(*function_to_bind)(Param1T)) {
504 assert(NULL != function_to_bind);
505 m_pthis = NULL; m_free_func = NULL;
506 base_type::bind(function_to_bind);
507 }
508
509 private:
510 void *m_pthis;
511 free_function_like_member_t m_free_func;
512
513 template< class Y >
514 ReturnT f_proxy(Param1T p1) const
515 {
516 typedef ReturnT(*type_free_function_like_member_t)(Y*, Param1T);
517
518 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis), p1);
519 }
520
521 template< class Y >
522 ReturnT f_proxy_const(Param1T p1) const
523 {
524 typedef ReturnT(*type_free_function_like_member_t)(const Y*, Param1T);
525
526 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis), p1);
527 }
528 };
529
530 template<class ReturnT, class Param1T, class Param2T>
531 class delegate<ReturnT, Param1T, Param2T, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid> :
532 public fastdelegate::FastDelegate2<Param1T, Param2T, ReturnT>
533 {
534 typedef ReturnT(*free_function_like_member_t)(void*, Param1T, Param2T);
535 typedef ReturnT(*free_function_like_member_const_t)(const void*, Param1T, Param2T);
536
537 typedef ReturnT(delegate::* f_proxy_type)(Param1T, Param2T) const;
538
539 template<class Y>
540 inline
541 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*, Param1T, Param2T)) const
542 { return &delegate::f_proxy<Y>; }
543
544 template<class Y>
545 inline
546 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*, Param1T, Param2T)) const
547 { return &delegate::f_proxy_const<Y>; }
548
549 template<class Y>
550 inline
551 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*, Param1T, Param2T)) const
552 { return &delegate::f_proxy_const<Y>; }
553
554 public:
555 typedef fastdelegate::FastDelegate2<Param1T, Param2T, ReturnT> base_type;
556
557 typedef delegate type;
558
559 delegate()
560 : base_type(),
561 m_pthis(NULL),
562 m_free_func(NULL)
563 { }
564
565 template < class X, class Y >
566 delegate(Y * pthis,
567 ReturnT(X::* function_to_bind)(Param1T, Param2T))
568 : base_type(pthis, function_to_bind),
569 m_pthis(NULL),
570 m_free_func(NULL)
571 {
572 assert(NULL != pthis);
573 assert(NULL != function_to_bind);
574 }
575
576 template < class X, class Y >
577 delegate(const Y *pthis,
578 ReturnT(X::* function_to_bind)(Param1T, Param2T) const)
579 : base_type(pthis, function_to_bind),
580 m_pthis(NULL),
581 m_free_func(NULL)
582 {
583 assert(NULL != pthis);
584 assert(NULL != function_to_bind);
585 }
586
587 template < class Y >
588 delegate(Y *pthis,
589 ReturnT(*function_to_bind)(Y*, Param1T, Param2T))
590 : base_type(this, get_proxy(pthis, function_to_bind)),
591 m_pthis(static_cast<void*>(pthis)),
592 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
593 { }
594
595 template < class Y >
596 delegate(Y *pthis,
597 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T))
598 : base_type(this, get_proxy(pthis, function_to_bind)),
599 m_pthis(static_cast<void*>(pthis)),
600 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
601 { }
602
603 template < class Y >
604 delegate(const Y *pthis,
605 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T))
606 : base_type(this, get_proxy(pthis, function_to_bind)),
607 m_pthis(static_cast<void*>(pthis)),
608 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
609 { }
610
611
612 delegate(ReturnT(*function_to_bind)(Param1T, Param2T))
613 : base_type(function_to_bind),
614 m_pthis(NULL),
615 m_free_func(NULL)
616 {
617 assert(NULL != function_to_bind);
618 }
619
620 delegate(const delegate &other)
621 {
622 {
623 f_proxy_type proxy = &delegate::f_proxy<delegate>;
624 base_type::bind(this, proxy);
625 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
626 if(other.m_free_func)
627 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
628 base_type::SetMemento(tmp);
629 }
630 using namespace std;
631 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
632 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
633 }
634
635 void operator=(const delegate &other)
636 {
637 {
638 f_proxy_type proxy = &delegate::f_proxy<delegate>;
639 base_type::bind(this, proxy);
640 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
641 if(other.m_free_func)
642 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
643 base_type::SetMemento(tmp);
644 }
645 using namespace std;
646 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
647 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
648 }
649
650 bool operator==(const delegate &other) const
651 {
652 if(!m_free_func && !other.m_free_func)
653 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
654
655 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
656 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
657 else
658 return false;
659 }
660
661 bool operator!=(const delegate &other) const
662 {
663 return !(*this == other);
664 }
665
666 bool operator<(const delegate &other) const
667 {
668 if(!m_free_func && !other.m_free_func)
669 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
670 if(m_pthis != other.m_pthis)
671 return m_pthis < other.m_pthis;
672 if(m_free_func != other.m_free_func)
673 return m_free_func < other.m_free_func;
674 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
675 }
676
677 bool operator>(const delegate &other) const
678 {
679 if(!m_free_func && !other.m_free_func)
680 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
681 if(m_pthis != other.m_pthis)
682 return m_pthis > other.m_pthis;
683 if(m_free_func != other.m_free_func)
684 return m_free_func > other.m_free_func;
685 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
686 }
687
688 template < class Y >
689 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y*, Param1T, Param2T)) {
690 this->clear();
691 m_pthis = static_cast<void*>(pthis);
692 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
693 bind(this, get_proxy(pthis, function_to_bind));
694 }
695
696 template < class Y >
697 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T)) {
698 this->clear();
699 m_pthis = static_cast<void*>(pthis);
700 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
701 bind(this, get_proxy(pthis, function_to_bind));
702 }
703
704 template < class Y >
705 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T)) {
706 this->clear();
707 m_pthis = static_cast<void*>(pthis);
708 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
709 bind(this, get_proxy(pthis, function_to_bind));
710 }
711
712 template < class X, class Y >
713 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T)) {
714 assert(NULL != pthis);
715 assert(NULL != function_to_bind);
716 m_pthis = NULL; m_free_func = NULL;
717 base_type::bind(pthis, function_to_bind);
718 }
719
720 template < class X, class Y >
721 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T) const) {
722 assert(NULL != pthis);
723 assert(NULL != function_to_bind);
724 m_pthis = NULL; m_free_func = NULL;
725 base_type::bind(pthis, function_to_bind);
726 }
727
728 inline void bind(ReturnT(*function_to_bind)(Param1T, Param2T)) {
729 assert(NULL != function_to_bind);
730 m_pthis = NULL; m_free_func = NULL;
731 base_type::bind(function_to_bind);
732 }
733
734 private:
735 void *m_pthis;
736 free_function_like_member_t m_free_func;
737
738 template< class Y >
739 ReturnT f_proxy(Param1T p1, Param2T p2) const
740 {
741 typedef ReturnT(*type_free_function_like_member_t)(Y*, Param1T, Param2T);
742
743 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis), p1, p2);
744 }
745
746 template< class Y >
747 ReturnT f_proxy_const(Param1T p1, Param2T p2) const
748 {
749 typedef ReturnT(*type_free_function_like_member_t)(const Y*, Param1T, Param2T);
750
751 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis), p1, p2);
752 }
753 };
754
755 template<class ReturnT, class Param1T, class Param2T, class Param3T>
756 class delegate<ReturnT, Param1T, Param2T, Param3T, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid> :
757 public fastdelegate::FastDelegate3<Param1T, Param2T, Param3T, ReturnT>
758 {
759 typedef ReturnT(*free_function_like_member_t)(void*, Param1T, Param2T, Param3T);
760
761 typedef ReturnT(delegate::* f_proxy_type)(Param1T, Param2T, Param3T) const;
762
763 template<class Y>
764 inline
765 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*, Param1T, Param2T, Param3T)) const
766 { return &delegate::f_proxy<Y>; }
767
768 template<class Y>
769 inline
770 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T)) const
771 { return &delegate::f_proxy_const<Y>; }
772
773 template<class Y>
774 inline
775 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T)) const
776 { return &delegate::f_proxy_const<Y>; }
777
778 public:
779 typedef fastdelegate::FastDelegate3<Param1T, Param2T, Param3T, ReturnT> base_type;
780
781 typedef delegate type;
782
783 delegate()
784 : base_type(),
785 m_pthis(NULL),
786 m_free_func(NULL)
787 { }
788
789 template < class X, class Y >
790 delegate(Y * pthis,
791 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T))
792 : base_type(pthis, function_to_bind),
793 m_pthis(NULL),
794 m_free_func(NULL)
795 {
796 assert(NULL != pthis);
797 assert(NULL != function_to_bind);
798 }
799
800 template < class X, class Y >
801 delegate(const Y *pthis,
802 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T) const)
803 : base_type(pthis, function_to_bind),
804 m_pthis(NULL),
805 m_free_func(NULL)
806 {
807 assert(NULL != pthis);
808 assert(NULL != function_to_bind);
809 }
810
811 template < class Y >
812 delegate(Y *pthis,
813 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T))
814 : base_type(this, get_proxy(pthis, function_to_bind)),
815 m_pthis(static_cast<void*>(pthis)),
816 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
817 { }
818
819 template < class Y >
820 delegate(Y *pthis,
821 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T))
822 : base_type(this, get_proxy(pthis, function_to_bind)),
823 m_pthis(static_cast<void*>(pthis)),
824 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
825 { }
826
827 template < class Y >
828 delegate(const Y *pthis,
829 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T))
830 : base_type(this, get_proxy(pthis, function_to_bind)),
831 m_pthis(static_cast<void*>(pthis)),
832 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
833 { }
834
835
836 delegate(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T))
837 : base_type(function_to_bind),
838 m_pthis(NULL),
839 m_free_func(NULL)
840 {
841 assert(NULL != function_to_bind);
842 }
843
844 delegate(const delegate &other)
845 {
846 {
847 f_proxy_type proxy = &delegate::f_proxy<delegate>;
848 base_type::bind(this, proxy);
849 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
850 if(other.m_free_func)
851 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
852 base_type::SetMemento(tmp);
853 }
854 using namespace std;
855 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
856 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
857 }
858
859 void operator=(const delegate &other)
860 {
861 {
862 f_proxy_type proxy = &delegate::f_proxy<delegate>;
863 base_type::bind(this, proxy);
864 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
865 if(other.m_free_func)
866 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
867 base_type::SetMemento(tmp);
868 }
869 using namespace std;
870 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
871 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
872 }
873
874 bool operator==(const delegate &other) const
875 {
876 if(!m_free_func && !other.m_free_func)
877 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
878
879 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
880 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
881 else
882 return false;
883 }
884
885 bool operator!=(const delegate &other) const
886 {
887 return !(*this == other);
888 }
889
890 bool operator<(const delegate &other) const
891 {
892 if(!m_free_func && !other.m_free_func)
893 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
894 if(m_pthis != other.m_pthis)
895 return m_pthis < other.m_pthis;
896 if(m_free_func != other.m_free_func)
897 return m_free_func < other.m_free_func;
898 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
899 }
900
901 bool operator>(const delegate &other) const
902 {
903 if(!m_free_func && !other.m_free_func)
904 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
905 if(m_pthis != other.m_pthis)
906 return m_pthis > other.m_pthis;
907 if(m_free_func != other.m_free_func)
908 return m_free_func > other.m_free_func;
909 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
910 }
911
912 template < class Y >
913 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T)) {
914 this->clear();
915 m_pthis = static_cast<void*>(pthis);
916 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
917 bind(this, get_proxy(pthis, function_to_bind));
918 }
919
920 template < class Y >
921 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T)) {
922 this->clear();
923 m_pthis = static_cast<void*>(pthis);
924 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
925 bind(this, get_proxy(pthis, function_to_bind));
926 }
927
928 template < class Y >
929 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T)) {
930 this->clear();
931 m_pthis = static_cast<void*>(pthis);
932 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
933 bind(this, get_proxy(pthis, function_to_bind));
934 }
935
936 template < class X, class Y >
937 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T)) {
938 assert(NULL != pthis);
939 assert(NULL != function_to_bind);
940 m_pthis = NULL; m_free_func = NULL;
941 base_type::bind(pthis, function_to_bind);
942 }
943
944 template < class X, class Y >
945 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T) const) {
946 assert(NULL != pthis);
947 assert(NULL != function_to_bind);
948 m_pthis = NULL; m_free_func = NULL;
949 base_type::bind(pthis, function_to_bind);
950 }
951
952 inline void bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T)) {
953 assert(NULL != function_to_bind);
954 m_pthis = NULL; m_free_func = NULL;
955 base_type::bind(function_to_bind);
956 }
957
958 private:
959 void *m_pthis;
960 free_function_like_member_t m_free_func;
961
962 template< class Y >
963 ReturnT f_proxy(Param1T p1, Param2T p2, Param3T p3) const
964 {
965 typedef ReturnT(*type_free_function_like_member_t)(Y*, Param1T, Param2T, Param3T);
966
967 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis), p1, p2, p3);
968 }
969
970 template< class Y >
971 ReturnT f_proxy_const(Param1T p1, Param2T p2, Param3T p3) const
972 {
973 typedef ReturnT(*type_free_function_like_member_t)(const Y*, Param1T, Param2T, Param3T);
974
975 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis), p1, p2, p3);
976 }
977 };
978
979 template<class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T>
980 class delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid> :
981 public fastdelegate::FastDelegate4<Param1T, Param2T, Param3T, Param4T, ReturnT>
982 {
983 typedef ReturnT(*free_function_like_member_t)(void*, Param1T, Param2T, Param3T, Param4T);
984
985 typedef ReturnT(delegate::* f_proxy_type)(Param1T, Param2T, Param3T, Param4T) const;
986
987 template<class Y>
988 inline
989 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*, Param1T, Param2T, Param3T, Param4T)) const
990 { return &delegate::f_proxy<Y>; }
991
992 template<class Y>
993 inline
994 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T)) const
995 { return &delegate::f_proxy_const<Y>; }
996
997 template<class Y>
998 inline
999 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T)) const
1000 { return &delegate::f_proxy_const<Y>; }
1001
1002 public:
1003 typedef fastdelegate::FastDelegate4<Param1T, Param2T, Param3T, Param4T, ReturnT> base_type;
1004
1005 typedef delegate type;
1006
1007 delegate()
1008 : base_type(),
1009 m_pthis(NULL),
1010 m_free_func(NULL)
1011 { }
1012
1013 template < class X, class Y >
1014 delegate(Y * pthis,
1015 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T))
1016 : base_type(pthis, function_to_bind),
1017 m_pthis(NULL),
1018 m_free_func(NULL)
1019 {
1020 assert(NULL != pthis);
1021 assert(NULL != function_to_bind);
1022 }
1023
1024 template < class X, class Y >
1025 delegate(const Y *pthis,
1026 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T) const)
1027 : base_type(pthis, function_to_bind),
1028 m_pthis(NULL),
1029 m_free_func(NULL)
1030 {
1031 assert(NULL != pthis);
1032 assert(NULL != function_to_bind);
1033 }
1034
1035 template < class Y >
1036 delegate(Y *pthis,
1037 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T))
1038 : base_type(this, get_proxy(pthis, function_to_bind)),
1039 m_pthis(static_cast<void*>(pthis)),
1040 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1041 { }
1042
1043 template < class Y >
1044 delegate(Y *pthis,
1045 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T))
1046 : base_type(this, get_proxy(pthis, function_to_bind)),
1047 m_pthis(static_cast<void*>(pthis)),
1048 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1049 { }
1050
1051 template < class Y >
1052 delegate(const Y *pthis,
1053 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T))
1054 : base_type(this, get_proxy(pthis, function_to_bind)),
1055 m_pthis(static_cast<void*>(pthis)),
1056 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1057 { }
1058
1059
1060 delegate(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T))
1061 : base_type(function_to_bind),
1062 m_pthis(NULL),
1063 m_free_func(NULL)
1064 {
1065 assert(NULL != function_to_bind);
1066 }
1067
1068 delegate(const delegate &other)
1069 {
1070 {
1071 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1072 base_type::bind(this, proxy);
1073 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1074 if(other.m_free_func)
1075 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1076 base_type::SetMemento(tmp);
1077 }
1078 using namespace std;
1079 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1080 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1081 }
1082
1083 void operator=(const delegate &other)
1084 {
1085 {
1086 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1087 base_type::bind(this, proxy);
1088 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1089 if(other.m_free_func)
1090 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1091 base_type::SetMemento(tmp);
1092 }
1093 using namespace std;
1094 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1095 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1096 }
1097
1098 bool operator==(const delegate &other) const
1099 {
1100 if(!m_free_func && !other.m_free_func)
1101 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
1102
1103 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
1104 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
1105 else
1106 return false;
1107 }
1108
1109 bool operator!=(const delegate &other) const
1110 {
1111 return !(*this == other);
1112 }
1113
1114 bool operator<(const delegate &other) const
1115 {
1116 if(!m_free_func && !other.m_free_func)
1117 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
1118 if(m_pthis != other.m_pthis)
1119 return m_pthis < other.m_pthis;
1120 if(m_free_func != other.m_free_func)
1121 return m_free_func < other.m_free_func;
1122 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
1123 }
1124
1125 bool operator>(const delegate &other) const
1126 {
1127 if(!m_free_func && !other.m_free_func)
1128 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
1129 if(m_pthis != other.m_pthis)
1130 return m_pthis > other.m_pthis;
1131 if(m_free_func != other.m_free_func)
1132 return m_free_func > other.m_free_func;
1133 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
1134 }
1135
1136 template < class Y >
1137 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T)) {
1138 this->clear();
1139 m_pthis = static_cast<void*>(pthis);
1140 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1141 bind(this, get_proxy(pthis, function_to_bind));
1142 }
1143
1144 template < class Y >
1145 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T)) {
1146 this->clear();
1147 m_pthis = static_cast<void*>(pthis);
1148 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1149 bind(this, get_proxy(pthis, function_to_bind));
1150 }
1151
1152 template < class Y >
1153 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T)) {
1154 this->clear();
1155 m_pthis = static_cast<void*>(pthis);
1156 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1157 bind(this, get_proxy(pthis, function_to_bind));
1158 }
1159
1160 template < class X, class Y >
1161 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T)) {
1162 assert(NULL != pthis);
1163 assert(NULL != function_to_bind);
1164 m_pthis = NULL; m_free_func = NULL;
1165 base_type::bind(pthis, function_to_bind);
1166 }
1167
1168 template < class X, class Y >
1169 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T) const) {
1170 assert(NULL != pthis);
1171 assert(NULL != function_to_bind);
1172 m_pthis = NULL; m_free_func = NULL;
1173 base_type::bind(pthis, function_to_bind);
1174 }
1175
1176 inline void bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T)) {
1177 assert(NULL != function_to_bind);
1178 m_pthis = NULL; m_free_func = NULL;
1179 base_type::bind(function_to_bind);
1180 }
1181
1182 private:
1183 void *m_pthis;
1184 free_function_like_member_t m_free_func;
1185
1186 template< class Y >
1187 ReturnT f_proxy(Param1T p1, Param2T p2, Param3T p3, Param4T p4) const
1188 {
1189 typedef ReturnT(*type_free_function_like_member_t)(Y*, Param1T, Param2T, Param3T, Param4T);
1190
1191 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis), p1, p2, p3, p4);
1192 }
1193
1194 template< class Y >
1195 ReturnT f_proxy_const(Param1T p1, Param2T p2, Param3T p3, Param4T p4) const
1196 {
1197 typedef ReturnT(*type_free_function_like_member_t)(const Y*, Param1T, Param2T, Param3T, Param4T);
1198
1199 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis), p1, p2, p3, p4);
1200 }
1201 };
1202
1203 template<class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T>
1204 class delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid> :
1205 public fastdelegate::FastDelegate5<Param1T, Param2T, Param3T, Param4T, Param5T, ReturnT>
1206 {
1207 typedef ReturnT(*free_function_like_member_t)(void*, Param1T, Param2T, Param3T, Param4T, Param5T);
1208
1209 typedef ReturnT(delegate::* f_proxy_type)(Param1T, Param2T, Param3T, Param4T, Param5T) const;
1210
1211 template<class Y>
1212 inline
1213 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T)) const
1214 { return &delegate::f_proxy<Y>; }
1215
1216 template<class Y>
1217 inline
1218 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T)) const
1219 { return &delegate::f_proxy_const<Y>; }
1220
1221 template<class Y>
1222 inline
1223 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T)) const
1224 { return &delegate::f_proxy_const<Y>; }
1225
1226 public:
1227 typedef fastdelegate::FastDelegate5<Param1T, Param2T, Param3T, Param4T, Param5T, ReturnT> base_type;
1228
1229 typedef delegate type;
1230
1231 delegate()
1232 : base_type(),
1233 m_pthis(NULL),
1234 m_free_func(NULL)
1235 { }
1236
1237 template < class X, class Y >
1238 delegate(Y * pthis,
1239 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T))
1240 : base_type(pthis, function_to_bind),
1241 m_pthis(NULL),
1242 m_free_func(NULL)
1243 {
1244 assert(NULL != pthis);
1245 assert(NULL != function_to_bind);
1246 }
1247
1248 template < class X, class Y >
1249 delegate(const Y *pthis,
1250 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T) const)
1251 : base_type(pthis, function_to_bind),
1252 m_pthis(NULL),
1253 m_free_func(NULL)
1254 {
1255 assert(NULL != pthis);
1256 assert(NULL != function_to_bind);
1257 }
1258
1259 template < class Y >
1260 delegate(Y *pthis,
1261 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T))
1262 : base_type(this, get_proxy(pthis, function_to_bind)),
1263 m_pthis(static_cast<void*>(pthis)),
1264 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1265 { }
1266
1267 template < class Y >
1268 delegate(Y *pthis,
1269 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T))
1270 : base_type(this, get_proxy(pthis, function_to_bind)),
1271 m_pthis(static_cast<void*>(pthis)),
1272 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1273 { }
1274
1275 template < class Y >
1276 delegate(const Y *pthis,
1277 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T))
1278 : base_type(this, get_proxy(pthis, function_to_bind)),
1279 m_pthis(static_cast<void*>(pthis)),
1280 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1281 { }
1282
1283
1284 delegate(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T))
1285 : base_type(function_to_bind),
1286 m_pthis(NULL),
1287 m_free_func(NULL)
1288 {
1289 assert(NULL != function_to_bind);
1290 }
1291
1292 delegate(const delegate &other)
1293 {
1294 {
1295 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1296 base_type::bind(this, proxy);
1297 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1298 if(other.m_free_func || other.m_free_func_const)
1299 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1300 base_type::SetMemento(tmp);
1301 }
1302 using namespace std;
1303 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1304 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1305 }
1306
1307 void operator=(const delegate &other)
1308 {
1309 {
1310 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1311 base_type::bind(this, proxy);
1312 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1313 if(other.m_free_func || other.m_free_func_const)
1314 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1315 base_type::SetMemento(tmp);
1316 }
1317 using namespace std;
1318 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1319 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1320 }
1321
1322 bool operator==(const delegate &other) const
1323 {
1324 if(!m_free_func && !other.m_free_func)
1325 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
1326
1327 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
1328 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
1329 else
1330 return false;
1331 }
1332
1333 bool operator!=(const delegate &other) const
1334 {
1335 return !(*this == other);
1336 }
1337
1338 bool operator<(const delegate &other) const
1339 {
1340 if(!m_free_func && !other.m_free_func)
1341 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
1342 if(m_pthis != other.m_pthis)
1343 return m_pthis < other.m_pthis;
1344 if(m_free_func != other.m_free_func)
1345 return m_free_func < other.m_free_func;
1346 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
1347 }
1348
1349 bool operator>(const delegate &other) const
1350 {
1351 if(!m_free_func && !other.m_free_func)
1352 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
1353 if(m_pthis != other.m_pthis)
1354 return m_pthis > other.m_pthis;
1355 if(m_free_func != other.m_free_func)
1356 return m_free_func > other.m_free_func;
1357 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
1358 }
1359
1360 template < class Y >
1361 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T)) {
1362 this->clear();
1363 m_pthis = static_cast<void*>(pthis);
1364 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1365 bind(this, get_proxy(pthis, function_to_bind));
1366 }
1367
1368 template < class Y >
1369 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T)) {
1370 this->clear();
1371 m_pthis = static_cast<void*>(pthis);
1372 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1373 bind(this, get_proxy(pthis, function_to_bind));
1374 }
1375
1376 template < class Y >
1377 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T)) {
1378 this->clear();
1379 m_pthis = static_cast<void*>(pthis);
1380 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1381 bind(this, get_proxy(pthis, function_to_bind));
1382 }
1383
1384 template < class X, class Y >
1385 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T)) {
1386 assert(NULL != pthis);
1387 assert(NULL != function_to_bind);
1388 m_pthis = NULL; m_free_func = NULL;
1389 base_type::bind(pthis, function_to_bind);
1390 }
1391
1392 template < class X, class Y >
1393 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T) const) {
1394 assert(NULL != pthis);
1395 assert(NULL != function_to_bind);
1396 m_pthis = NULL; m_free_func = NULL;
1397 base_type::bind(pthis, function_to_bind);
1398 }
1399
1400 inline void bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T)) {
1401 assert(NULL != function_to_bind);
1402 m_pthis = NULL; m_free_func = NULL;
1403 base_type::bind(function_to_bind);
1404 }
1405
1406 private:
1407 void *m_pthis;
1408 free_function_like_member_t m_free_func;
1409
1410 template< class Y >
1411 ReturnT f_proxy(Param1T p1, Param2T p2, Param3T p3, Param4T p4, Param5T p5) const
1412 {
1413 typedef ReturnT(*type_free_function_like_member_t)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T);
1414
1415 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis), p1, p2, p3, p4, p5);
1416 }
1417
1418 template< class Y >
1419 ReturnT f_proxy_const(Param1T p1, Param2T p2, Param3T p3, Param4T p4, Param5T p5) const
1420 {
1421 typedef ReturnT(*type_free_function_like_member_t)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T);
1422
1423 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis), p1, p2, p3, p4, p5);
1424 }
1425 };
1426
1427 template<class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T>
1428 class delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, detail::DefaultVoid, detail::DefaultVoid, detail::DefaultVoid> :
1429 public fastdelegate::FastDelegate6<Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, ReturnT>
1430 {
1431 typedef ReturnT(*free_function_like_member_t)(void*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T);
1432 typedef ReturnT(*free_function_like_member_const_t)(const void*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T);
1433
1434 typedef ReturnT(delegate::* f_proxy_type)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T) const;
1435
1436 template<class Y>
1437 inline
1438 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T)) const
1439 { return &delegate::f_proxy<Y>; }
1440
1441 template<class Y>
1442 inline
1443 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T)) const
1444 { return &delegate::f_proxy_const<Y>; }
1445
1446 template<class Y>
1447 inline
1448 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T)) const
1449 { return &delegate::f_proxy_const<Y>; }
1450
1451 public:
1452 typedef fastdelegate::FastDelegate6<Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, ReturnT> base_type;
1453
1454 typedef delegate type;
1455
1456 delegate()
1457 : base_type(),
1458 m_pthis(NULL),
1459 m_free_func(NULL)
1460 { }
1461
1462 template < class X, class Y >
1463 delegate(Y * pthis,
1464 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
1465 : base_type(pthis, function_to_bind),
1466 m_pthis(NULL),
1467 m_free_func(NULL)
1468 {
1469 assert(NULL != pthis);
1470 assert(NULL != function_to_bind);
1471 }
1472
1473 template < class X, class Y >
1474 delegate(const Y *pthis,
1475 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T) const)
1476 : base_type(pthis, function_to_bind),
1477 m_pthis(NULL),
1478 m_free_func(NULL)
1479 {
1480 assert(NULL != pthis);
1481 assert(NULL != function_to_bind);
1482 }
1483
1484 template < class Y >
1485 delegate(Y *pthis,
1486 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
1487 : base_type(this, get_proxy(pthis, function_to_bind)),
1488 m_pthis(static_cast<void*>(pthis)),
1489 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1490 { }
1491
1492 template < class Y >
1493 delegate(Y *pthis,
1494 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
1495 : base_type(this, get_proxy(pthis, function_to_bind)),
1496 m_pthis(static_cast<void*>(pthis)),
1497 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1498 { }
1499
1500 template < class Y >
1501 delegate(const Y *pthis,
1502 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
1503 : base_type(this, get_proxy(pthis, function_to_bind)),
1504 m_pthis(static_cast<void*>(pthis)),
1505 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1506 { }
1507
1508
1509 delegate(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
1510 : base_type(function_to_bind),
1511 m_pthis(NULL),
1512 m_free_func(NULL)
1513 {
1514 assert(NULL != function_to_bind);
1515 }
1516
1517 delegate(const delegate &other)
1518 {
1519 {
1520 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1521 base_type::bind(this, proxy);
1522 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1523 if(other.m_free_func)
1524 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1525 base_type::SetMemento(tmp);
1526 }
1527 using namespace std;
1528 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1529 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1530 }
1531
1532 void operator=(const delegate &other)
1533 {
1534 {
1535 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1536 base_type::bind(this, proxy);
1537 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1538 if(other.m_free_func)
1539 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1540 base_type::SetMemento(tmp);
1541 }
1542 using namespace std;
1543 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1544 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1545 }
1546
1547 bool operator==(const delegate &other) const
1548 {
1549 if(!m_free_func && !other.m_free_func)
1550 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
1551
1552 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
1553 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
1554 else
1555 return false;
1556 }
1557
1558 bool operator!=(const delegate &other) const
1559 {
1560 return !(*this == other);
1561 }
1562
1563 bool operator<(const delegate &other) const
1564 {
1565 if(!m_free_func && !other.m_free_func)
1566 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
1567 if(m_pthis != other.m_pthis)
1568 return m_pthis < other.m_pthis;
1569 if(m_free_func != other.m_free_func)
1570 return m_free_func < other.m_free_func;
1571 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
1572 }
1573
1574 bool operator>(const delegate &other) const
1575 {
1576 if(!m_free_func && !other.m_free_func)
1577 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
1578 if(m_pthis != other.m_pthis)
1579 return m_pthis > other.m_pthis;
1580 if(m_free_func != other.m_free_func)
1581 return m_free_func > other.m_free_func;
1582 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
1583 }
1584
1585 template < class Y >
1586 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T)) {
1587 this->clear();
1588 m_pthis = static_cast<void*>(pthis);
1589 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1590 bind(this, get_proxy(pthis, function_to_bind));
1591 }
1592
1593 template < class Y >
1594 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T)) {
1595 this->clear();
1596 m_pthis = static_cast<void*>(pthis);
1597 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1598 bind(this, get_proxy(pthis, function_to_bind));
1599 }
1600
1601 template < class Y >
1602 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T)) {
1603 this->clear();
1604 m_pthis = static_cast<void*>(pthis);
1605 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1606 bind(this, get_proxy(pthis, function_to_bind));
1607 }
1608
1609 template < class X, class Y >
1610 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T)) {
1611 assert(NULL != pthis);
1612 assert(NULL != function_to_bind);
1613 m_pthis = NULL; m_free_func = NULL;
1614 base_type::bind(pthis, function_to_bind);
1615 }
1616
1617 template < class X, class Y >
1618 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T) const) {
1619 assert(NULL != pthis);
1620 assert(NULL != function_to_bind);
1621 m_pthis = NULL; m_free_func = NULL;
1622 base_type::bind(pthis, function_to_bind);
1623 }
1624
1625 inline void bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T)) {
1626 assert(NULL != function_to_bind);
1627 m_pthis = NULL; m_free_func = NULL;
1628 base_type::bind(function_to_bind);
1629 }
1630
1631 private:
1632 void *m_pthis;
1633 free_function_like_member_t m_free_func;
1634
1635 template< class Y >
1636 ReturnT f_proxy(Param1T p1, Param2T p2, Param3T p3, Param4T p4, Param5T p5, Param6T p6) const
1637 {
1638 typedef ReturnT(*type_free_function_like_member_t)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T);
1639
1640 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis), p1, p2, p3, p4, p5, p6);
1641 }
1642
1643 template< class Y >
1644 ReturnT f_proxy_const(Param1T p1, Param2T p2, Param3T p3, Param4T p4, Param5T p5, Param6T p6) const
1645 {
1646 typedef ReturnT(*type_free_function_like_member_t)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T);
1647
1648 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis), p1, p2, p3, p4, p5, p6);
1649 }
1650 };
1651
1652 template<class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T>
1653 class delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, detail::DefaultVoid, detail::DefaultVoid> :
1654 public fastdelegate::FastDelegate7<Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, ReturnT>
1655 {
1656 typedef ReturnT(*free_function_like_member_t)(void*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T);
1657
1658 typedef ReturnT(delegate::* f_proxy_type)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T) const;
1659
1660 template<class Y>
1661 inline
1662 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) const
1663 { return &delegate::f_proxy<Y>; }
1664
1665 template<class Y>
1666 inline
1667 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) const
1668 { return &delegate::f_proxy_const<Y>; }
1669
1670 template<class Y>
1671 inline
1672 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) const
1673 { return &delegate::f_proxy_const<Y>; }
1674
1675 public:
1676 typedef fastdelegate::FastDelegate7<Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, ReturnT> base_type;
1677
1678 typedef delegate type;
1679
1680 delegate()
1681 : base_type(),
1682 m_pthis(NULL),
1683 m_free_func(NULL)
1684 { }
1685
1686 template < class X, class Y >
1687 delegate(Y * pthis,
1688 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
1689 : base_type(pthis, function_to_bind),
1690 m_pthis(NULL),
1691 m_free_func(NULL)
1692 {
1693 assert(NULL != pthis);
1694 assert(NULL != function_to_bind);
1695 }
1696
1697 template < class X, class Y >
1698 delegate(const Y *pthis,
1699 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T) const)
1700 : base_type(pthis, function_to_bind),
1701 m_pthis(NULL),
1702 m_free_func(NULL)
1703 {
1704 assert(NULL != pthis);
1705 assert(NULL != function_to_bind);
1706 }
1707
1708 template < class Y >
1709 delegate(Y *pthis,
1710 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
1711 : base_type(this, get_proxy(pthis, function_to_bind)),
1712 m_pthis(static_cast<void*>(pthis)),
1713 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1714 { }
1715
1716 template < class Y >
1717 delegate(Y *pthis,
1718 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
1719 : base_type(this, get_proxy(pthis, function_to_bind)),
1720 m_pthis(static_cast<void*>(pthis)),
1721 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1722 { }
1723
1724 template < class Y >
1725 delegate(const Y *pthis,
1726 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
1727 : base_type(this, get_proxy(pthis, function_to_bind)),
1728 m_pthis(static_cast<void*>(pthis)),
1729 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1730 { }
1731
1732
1733 delegate(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
1734 : base_type(function_to_bind),
1735 m_pthis(NULL),
1736 m_free_func(NULL)
1737 {
1738 assert(NULL != function_to_bind);
1739 }
1740
1741 delegate(const delegate &other)
1742 {
1743 {
1744 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1745 base_type::bind(this, proxy);
1746 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1747 if(other.m_free_func)
1748 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1749 base_type::SetMemento(tmp);
1750 }
1751 using namespace std;
1752 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1753 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1754 }
1755
1756 void operator=(const delegate &other)
1757 {
1758 {
1759 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1760 base_type::bind(this, proxy);
1761 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1762 if(other.m_free_func)
1763 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1764 base_type::SetMemento(tmp);
1765 }
1766 using namespace std;
1767 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1768 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1769 }
1770
1771 bool operator==(const delegate &other) const
1772 {
1773 if(!m_free_func && !other.m_free_func)
1774 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
1775
1776 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
1777 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
1778 else
1779 return false;
1780 }
1781
1782 bool operator!=(const delegate &other) const
1783 {
1784 return !(*this == other);
1785 }
1786
1787 bool operator<(const delegate &other) const
1788 {
1789 if(!m_free_func && !other.m_free_func)
1790 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
1791 if(m_pthis != other.m_pthis)
1792 return m_pthis < other.m_pthis;
1793 if(m_free_func != other.m_free_func)
1794 return m_free_func < other.m_free_func;
1795 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
1796 }
1797
1798 bool operator>(const delegate &other) const
1799 {
1800 if(!m_free_func && !other.m_free_func)
1801 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
1802 if(m_pthis != other.m_pthis)
1803 return m_pthis > other.m_pthis;
1804 if(m_free_func != other.m_free_func)
1805 return m_free_func > other.m_free_func;
1806 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
1807 }
1808
1809 template < class Y >
1810 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) {
1811 this->clear();
1812 m_pthis = static_cast<void*>(pthis);
1813 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1814 bind(this, get_proxy(pthis, function_to_bind));
1815 }
1816
1817 template < class Y >
1818 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) {
1819 this->clear();
1820 m_pthis = static_cast<void*>(pthis);
1821 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1822 bind(this, get_proxy(pthis, function_to_bind));
1823 }
1824
1825 template < class Y >
1826 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) {
1827 this->clear();
1828 m_pthis = static_cast<void*>(pthis);
1829 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
1830 bind(this, get_proxy(pthis, function_to_bind));
1831 }
1832
1833 template < class X, class Y >
1834 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) {
1835 assert(NULL != pthis);
1836 assert(NULL != function_to_bind);
1837 m_pthis = NULL; m_free_func = NULL;
1838 base_type::bind(pthis, function_to_bind);
1839 }
1840
1841 template < class X, class Y >
1842 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T) const) {
1843 assert(NULL != pthis);
1844 assert(NULL != function_to_bind);
1845 m_pthis = NULL; m_free_func = NULL;
1846 base_type::bind(pthis, function_to_bind);
1847 }
1848
1849 inline void bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) {
1850 assert(NULL != function_to_bind);
1851 m_pthis = NULL; m_free_func = NULL;
1852 base_type::bind(function_to_bind);
1853 }
1854
1855 private:
1856 void *m_pthis;
1857 free_function_like_member_t m_free_func;
1858
1859 template< class Y >
1860 ReturnT f_proxy(Param1T p1, Param2T p2, Param3T p3, Param4T p4, Param5T p5, Param6T p6, Param7T p7) const
1861 {
1862 typedef ReturnT(*type_free_function_like_member_t)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T);
1863
1864 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis), p1, p2, p3, p4, p5, p6, p7);
1865 }
1866
1867 template< class Y >
1868 ReturnT f_proxy_const(Param1T p1, Param2T p2, Param3T p3, Param4T p4, Param5T p5, Param6T p6, Param7T p7) const
1869 {
1870 typedef ReturnT(*type_free_function_like_member_t)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T);
1871
1872 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis), p1, p2, p3, p4, p5, p6, p7);
1873 }
1874 };
1875
1876 template<class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T, class Param8T>
1877 class delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T, detail::DefaultVoid> :
1878 public fastdelegate::FastDelegate8<Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T, ReturnT>
1879 {
1880 typedef ReturnT(*free_function_like_member_t)(void*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T);
1881 typedef ReturnT(*free_function_like_member_const_t)(const void*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T);
1882
1883 typedef ReturnT(delegate::* f_proxy_type)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T) const;
1884
1885 template<class Y>
1886 inline
1887 f_proxy_type get_proxy(Y*, ReturnT(*)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) const
1888 { return &delegate::f_proxy<Y>; }
1889
1890 template<class Y>
1891 inline
1892 f_proxy_type get_proxy(Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) const
1893 { return &delegate::f_proxy_const<Y>; }
1894
1895 template<class Y>
1896 inline
1897 f_proxy_type get_proxy(const Y*, ReturnT(*)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T)) const
1898 { return &delegate::f_proxy_const<Y>; }
1899
1900 public:
1901 typedef fastdelegate::FastDelegate8<Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T, ReturnT> base_type;
1902
1903 typedef delegate type;
1904
1905 delegate()
1906 : base_type(),
1907 m_pthis(NULL),
1908 m_free_func(NULL)
1909 { }
1910
1911 template < class X, class Y >
1912 delegate(Y * pthis,
1913 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
1914 : base_type(pthis, function_to_bind),
1915 m_pthis(NULL),
1916 m_free_func(NULL)
1917 {
1918 assert(NULL != pthis);
1919 assert(NULL != function_to_bind);
1920 }
1921
1922 template < class X, class Y >
1923 delegate(const Y *pthis,
1924 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T) const)
1925 : base_type(pthis, function_to_bind),
1926 m_pthis(NULL),
1927 m_free_func(NULL)
1928 {
1929 assert(NULL != pthis);
1930 assert(NULL != function_to_bind);
1931 }
1932
1933 template < class Y >
1934 delegate(Y *pthis,
1935 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
1936 : base_type(this, get_proxy(pthis, function_to_bind)),
1937 m_pthis(static_cast<void*>(pthis)),
1938 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1939 { }
1940
1941 template < class Y >
1942 delegate(Y *pthis,
1943 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
1944 : base_type(this, get_proxy(pthis, function_to_bind)),
1945 m_pthis(static_cast<void*>(pthis)),
1946 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1947 { }
1948
1949 template < class Y >
1950 delegate(const Y *pthis,
1951 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
1952 : base_type(this, get_proxy(pthis, function_to_bind)),
1953 m_pthis(static_cast<void*>(pthis)),
1954 m_free_func(reinterpret_cast<free_function_like_member_t>(function_to_bind))
1955 { }
1956
1957
1958 delegate(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
1959 : base_type(function_to_bind),
1960 m_pthis(NULL),
1961 m_free_func(NULL)
1962 {
1963 assert(NULL != function_to_bind);
1964 }
1965
1966 delegate(const delegate &other)
1967 {
1968 {
1969 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1970 base_type::bind(this, proxy);
1971 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1972 if(other.m_free_func)
1973 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1974 base_type::SetMemento(tmp);
1975 }
1976 using namespace std;
1977 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1978 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1979 }
1980
1981 void operator=(const delegate &other)
1982 {
1983 {
1984 f_proxy_type proxy = &delegate::f_proxy<delegate>;
1985 base_type::bind(this, proxy);
1986 fastdelegate::DelegateMemento tmp = (base_type(other)).GetMemento();
1987 if(other.m_free_func)
1988 detail::DelegateMementoHack::copy_pthis(tmp, base_type::GetMemento());
1989 base_type::SetMemento(tmp);
1990 }
1991 using namespace std;
1992 memcpy(&m_pthis, &other.m_pthis, sizeof(m_pthis));
1993 memcpy(&m_free_func, &other.m_free_func, sizeof(m_free_func));
1994 }
1995
1996 bool operator==(const delegate &other) const
1997 {
1998 if(!m_free_func && !other.m_free_func)
1999 return ( static_cast<const base_type&>(*this) == static_cast<const base_type&>(other) );
2000
2001 if(m_pthis == other.m_pthis && m_free_func == other.m_free_func)
2002 return detail::DelegateMementoHack::is_equal_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
2003 else
2004 return false;
2005 }
2006
2007 bool operator!=(const delegate &other) const
2008 {
2009 return !(*this == other);
2010 }
2011
2012 bool operator<(const delegate &other) const
2013 {
2014 if(!m_free_func && !other.m_free_func)
2015 return ( static_cast<const base_type&>(*this) < static_cast<const base_type&>(other) );
2016 if(m_pthis != other.m_pthis)
2017 return m_pthis < other.m_pthis;
2018 if(m_free_func != other.m_free_func)
2019 return m_free_func < other.m_free_func;
2020 return detail::DelegateMementoHack::is_less_pFunction((base_type(*this)).GetMemento(), (base_type(other)).GetMemento());
2021 }
2022
2023 bool operator>(const delegate &other) const
2024 {
2025 if(!m_free_func && !other.m_free_func)
2026 return ( static_cast<const base_type&>(*this) > static_cast<const base_type&>(other) );
2027 if(m_pthis != other.m_pthis)
2028 return m_pthis > other.m_pthis;
2029 if(m_free_func != other.m_free_func)
2030 return m_free_func > other.m_free_func;
2031 return detail::DelegateMementoHack::is_less_pFunction((base_type(other)).GetMemento(), (base_type(*this)).GetMemento());
2032 }
2033
2034 template < class Y >
2035 inline void bind(Y *pthis, ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T)) {
2036 this->clear();
2037 m_pthis = static_cast<void*>(pthis);
2038 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
2039 bind(this, get_proxy(pthis, function_to_bind));
2040 }
2041
2042 template < class Y >
2043 inline void bind(Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T)) {
2044 this->clear();
2045 m_pthis = static_cast<void*>(pthis);
2046 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
2047 bind(this, get_proxy(pthis, function_to_bind));
2048 }
2049
2050 template < class Y >
2051 inline void bind(const Y *pthis, ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T)) {
2052 this->clear();
2053 m_pthis = static_cast<void*>(pthis);
2054 m_free_func = reinterpret_cast<free_function_like_member_t>(function_to_bind);
2055 bind(this, get_proxy(pthis, function_to_bind));
2056 }
2057
2058 template < class X, class Y >
2059 inline void bind(Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T)) {
2060 assert(NULL != pthis);
2061 assert(NULL != function_to_bind);
2062 m_pthis = NULL; m_free_func = NULL;
2063 base_type::bind(pthis, function_to_bind);
2064 }
2065
2066 template < class X, class Y >
2067 inline void bind(const Y *pthis, ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T) const) {
2068 assert(NULL != pthis);
2069 assert(NULL != function_to_bind);
2070 m_pthis = NULL; m_free_func = NULL;
2071 base_type::bind(pthis, function_to_bind);
2072 }
2073
2074 inline void bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T)) {
2075 assert(NULL != function_to_bind);
2076 m_pthis = NULL; m_free_func = NULL;
2077 base_type::bind(function_to_bind);
2078 }
2079
2080 private:
2081 void *m_pthis;
2082 free_function_like_member_t m_free_func;
2083
2084 template< class Y >
2085 ReturnT f_proxy(Param1T p1, Param2T p2, Param3T p3, Param4T p4, Param5T p5, Param6T p6, Param7T p7, Param8T p8) const
2086 {
2087 typedef ReturnT(*type_free_function_like_member_t)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T);
2088
2089 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<Y*>(m_pthis), p1, p2, p3, p4, p5, p6, p7, p8);
2090 }
2091
2092 template< class Y >
2093 ReturnT f_proxy_const(Param1T p1, Param2T p2, Param3T p3, Param4T p4, Param5T p5, Param6T p6, Param7T p7, Param8T p8) const
2094 {
2095 typedef ReturnT(*type_free_function_like_member_t)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T);
2096
2097 return reinterpret_cast<type_free_function_like_member_t>(m_free_func)(static_cast<const Y*>(m_pthis), p1, p2, p3, p4, p5, p6, p7, p8);
2098 }
2099 };
2100
2101 template < class X, class Y, class ReturnT >
2102 delegate<ReturnT>
2103 bind(Y * pthis,
2104 ReturnT(X::* function_to_bind)())
2105 {
2106 return delegate<ReturnT>(pthis, function_to_bind);
2107 }
2108
2109 template < class X, class Y, class ReturnT >
2110 delegate<ReturnT>
2111 bind(const Y *pthis,
2112 ReturnT(X::* function_to_bind)() const)
2113 {
2114 return delegate<ReturnT>(pthis, function_to_bind);
2115 }
2116
2117 template < class Y, class ReturnT >
2118 delegate<ReturnT>
2119 bind(Y *pthis,
2120 ReturnT(*function_to_bind)(Y*))
2121 {
2122 return delegate<ReturnT>(pthis, function_to_bind);
2123 }
2124
2125 template < class Y, class ReturnT >
2126 delegate<ReturnT>
2127 bind(Y *pthis,
2128 ReturnT(*function_to_bind)(const Y*))
2129 {
2130 return delegate<ReturnT>(pthis, function_to_bind);
2131 }
2132
2133 template < class ReturnT >
2134 delegate<ReturnT>
2135 bind(ReturnT(*function_to_bind)())
2136 {
2137 return delegate<ReturnT>(function_to_bind);
2138 }
2139
2140 template < class X, class Y, class ReturnT, class Param1T >
2141 delegate<ReturnT, Param1T>
2142 bind(Y * pthis,
2143 ReturnT(X::* function_to_bind)(Param1T))
2144 {
2145 return delegate<ReturnT, Param1T>(pthis, function_to_bind);
2146 }
2147
2148 template < class X, class Y, class ReturnT, class Param1T >
2149 delegate<ReturnT, Param1T>
2150 bind(const Y *pthis,
2151 ReturnT(X::* function_to_bind)(Param1T) const)
2152 {
2153 return delegate<ReturnT, Param1T>(pthis, function_to_bind);
2154 }
2155
2156 template < class Y, class ReturnT, class Param1T >
2157 delegate<ReturnT, Param1T>
2158 bind(Y *pthis,
2159 ReturnT(*function_to_bind)(Y*, Param1T))
2160 {
2161 return delegate<ReturnT, Param1T>(pthis, function_to_bind);
2162 }
2163
2164 template < class Y, class ReturnT, class Param1T >
2165 delegate<ReturnT, Param1T>
2166 bind(Y *pthis,
2167 ReturnT(*function_to_bind)(const Y*, Param1T))
2168 {
2169 return delegate<ReturnT, Param1T>(pthis, function_to_bind);
2170 }
2171
2172 template < class ReturnT, class Param1T >
2173 delegate<ReturnT, Param1T>
2174 bind(ReturnT(*function_to_bind)(Param1T))
2175 {
2176 return delegate<ReturnT, Param1T>(function_to_bind);
2177 }
2178
2179 template < class X, class Y, class ReturnT, class Param1T, class Param2T >
2180 delegate<ReturnT, Param1T, Param2T>
2181 bind(Y * pthis,
2182 ReturnT(X::* function_to_bind)(Param1T, Param2T))
2183 {
2184 return delegate<ReturnT, Param1T, Param2T>(pthis, function_to_bind);
2185 }
2186
2187 template < class X, class Y, class ReturnT, class Param1T, class Param2T >
2188 delegate<ReturnT, Param1T, Param2T>
2189 bind(const Y *pthis,
2190 ReturnT(X::* function_to_bind)(Param1T, Param2T) const)
2191 {
2192 return delegate<ReturnT, Param1T, Param2T>(pthis, function_to_bind);
2193 }
2194
2195 template < class Y, class ReturnT, class Param1T, class Param2T >
2196 delegate<ReturnT, Param1T, Param2T>
2197 bind(Y *pthis,
2198 ReturnT(*function_to_bind)(Y*, Param1T, Param2T))
2199 {
2200 return delegate<ReturnT, Param1T, Param2T>(pthis, function_to_bind);
2201 }
2202
2203 template < class Y, class ReturnT, class Param1T, class Param2T >
2204 delegate<ReturnT, Param1T, Param2T>
2205 bind(Y *pthis,
2206 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T))
2207 {
2208 return delegate<ReturnT, Param1T, Param2T>(pthis, function_to_bind);
2209 }
2210
2211 template < class ReturnT, class Param1T, class Param2T >
2212 delegate<ReturnT, Param1T, Param2T>
2213 bind(ReturnT(*function_to_bind)(Param1T, Param2T))
2214 {
2215 return delegate<ReturnT, Param1T, Param2T>(function_to_bind);
2216 }
2217
2218 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T >
2219 delegate<ReturnT, Param1T, Param2T, Param3T>
2220 bind(Y * pthis,
2221 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T))
2222 {
2223 return delegate<ReturnT, Param1T, Param2T, Param3T>(pthis, function_to_bind);
2224 }
2225
2226 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T >
2227 delegate<ReturnT, Param1T, Param2T, Param3T>
2228 bind(const Y *pthis,
2229 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T) const)
2230 {
2231 return delegate<ReturnT, Param1T, Param2T, Param3T>(pthis, function_to_bind);
2232 }
2233
2234 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T >
2235 delegate<ReturnT, Param1T, Param2T, Param3T>
2236 bind(Y *pthis,
2237 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T))
2238 {
2239 return delegate<ReturnT, Param1T, Param2T, Param3T>(pthis, function_to_bind);
2240 }
2241
2242 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T >
2243 delegate<ReturnT, Param1T, Param2T, Param3T>
2244 bind(Y *pthis,
2245 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T))
2246 {
2247 return delegate<ReturnT, Param1T, Param2T, Param3T>(pthis, function_to_bind);
2248 }
2249
2250 template < class ReturnT, class Param1T, class Param2T, class Param3T >
2251 delegate<ReturnT, Param1T, Param2T, Param3T>
2252 bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T))
2253 {
2254 return delegate<ReturnT, Param1T, Param2T, Param3T>(function_to_bind);
2255 }
2256
2257 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T >
2258 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>
2259 bind(Y * pthis,
2260 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T))
2261 {
2262 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>(pthis, function_to_bind);
2263 }
2264
2265 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T >
2266 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>
2267 bind(const Y *pthis,
2268 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T) const)
2269 {
2270 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>(pthis, function_to_bind);
2271 }
2272
2273 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T >
2274 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>
2275 bind(Y *pthis,
2276 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T))
2277 {
2278 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>(pthis, function_to_bind);
2279 }
2280
2281 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T >
2282 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>
2283 bind(Y *pthis,
2284 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T))
2285 {
2286 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>(pthis, function_to_bind);
2287 }
2288
2289 template < class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T >
2290 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>
2291 bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T))
2292 {
2293 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T>(function_to_bind);
2294 }
2295
2296 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T >
2297 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>
2298 bind(Y * pthis,
2299 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T))
2300 {
2301 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>(pthis, function_to_bind);
2302 }
2303
2304 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T >
2305 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>
2306 bind(const Y *pthis,
2307 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T) const)
2308 {
2309 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>(pthis, function_to_bind);
2310 }
2311
2312 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T >
2313 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>
2314 bind(Y *pthis,
2315 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T))
2316 {
2317 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>(pthis, function_to_bind);
2318 }
2319
2320 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T >
2321 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>
2322 bind(Y *pthis,
2323 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T))
2324 {
2325 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>(pthis, function_to_bind);
2326 }
2327
2328 template < class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T >
2329 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>
2330 bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T))
2331 {
2332 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T>(function_to_bind);
2333 }
2334
2335 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T >
2336 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>
2337 bind(Y * pthis,
2338 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
2339 {
2340 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>(pthis, function_to_bind);
2341 }
2342
2343 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T >
2344 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>
2345 bind(const Y *pthis,
2346 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T) const)
2347 {
2348 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>(pthis, function_to_bind);
2349 }
2350
2351 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T >
2352 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>
2353 bind(Y *pthis,
2354 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
2355 {
2356 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>(pthis, function_to_bind);
2357 }
2358
2359 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T >
2360 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>
2361 bind(Y *pthis,
2362 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
2363 {
2364 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>(pthis, function_to_bind);
2365 }
2366
2367 template < class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T >
2368 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>
2369 bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T))
2370 {
2371 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T>(function_to_bind);
2372 }
2373
2374 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T >
2375 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>
2376 bind(Y * pthis,
2377 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
2378 {
2379 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>(pthis, function_to_bind);
2380 }
2381
2382 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T >
2383 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>
2384 bind(const Y *pthis,
2385 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T) const)
2386 {
2387 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>(pthis, function_to_bind);
2388 }
2389
2390 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T >
2391 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>
2392 bind(Y *pthis,
2393 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
2394 {
2395 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>(pthis, function_to_bind);
2396 }
2397
2398 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T >
2399 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>
2400 bind(Y *pthis,
2401 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
2402 {
2403 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>(pthis, function_to_bind);
2404 }
2405
2406 template < class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T >
2407 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>
2408 bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T))
2409 {
2410 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T>(function_to_bind);
2411 }
2412
2413 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T, class Param8T >
2414 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>
2415 bind(Y * pthis,
2416 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
2417 {
2418 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>(pthis, function_to_bind);
2419 }
2420
2421 template < class X, class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T, class Param8T >
2422 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>
2423 bind(const Y *pthis,
2424 ReturnT(X::* function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T) const)
2425 {
2426 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>(pthis, function_to_bind);
2427 }
2428
2429 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T, class Param8T >
2430 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>
2431 bind(Y *pthis,
2432 ReturnT(*function_to_bind)(Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
2433 {
2434 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>(pthis, function_to_bind);
2435 }
2436
2437 template < class Y, class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T, class Param8T >
2438 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>
2439 bind(Y *pthis,
2440 ReturnT(*function_to_bind)(const Y*, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
2441 {
2442 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>(pthis, function_to_bind);
2443 }
2444
2445 template < class ReturnT, class Param1T, class Param2T, class Param3T, class Param4T, class Param5T, class Param6T, class Param7T, class Param8T >
2446 delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>
2447 bind(ReturnT(*function_to_bind)(Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T))
2448 {
2449 return delegate<ReturnT, Param1T, Param2T, Param3T, Param4T, Param5T, Param6T, Param7T, Param8T>(function_to_bind);
2450 }
2451}
2452
2453
2454#endif // DELEGATE_H