sourcehook/FastDelegate.h
author David Anderson <dvander@alliedmods.net>
Tue Sep 13 22:16:29 2005 +0000 (2005-09-13)
changeset 110 77e7acc57f67
parent 48 a52dba4f8ed9
child 123 53e819ac032a
permissions -rw-r--r--
Fixed some more template bugs
     1 //						FastDelegate.h 
     2 //	Efficient delegates in C++ that generate only two lines of asm code!
     3 //  Documentation is found at http://www.codeproject.com/cpp/FastDelegate.asp
     4 //
     5 //						- Don Clugston, Mar 2004.
     6 //		Major contributions were made by Jody Hagins.
     7 // History:
     8 // 24-Apr-04 1.0  Submitted to CodeProject. 
     9 // 28-Apr-04 1.1  * Prevent most unsafe uses of evil static function hack.
    10 //				  * Improved syntax for horrible_cast (thanks Paul Bludov).
    11 //				  * Tested on Metrowerks MWCC and Intel ICL (IA32)
    12 //				  * Compiled, but not run, on Comeau C++ and Intel Itanium ICL.
    13 //	27-Jun-04 1.2 * Now works on Borland C++ Builder 5.5
    14 //				  * Now works on /clr "managed C++" code on VC7, VC7.1
    15 //				  * Comeau C++ now compiles without warnings.
    16 //				  * Prevent the virtual inheritance case from being used on 
    17 //					  VC6 and earlier, which generate incorrect code.
    18 //				  * Improved warning and error messages. Non-standard hacks
    19 //					 now have compile-time checks to make them safer.
    20 //				  * implicit_cast used instead of static_cast in many cases.
    21 //				  * If calling a const member function, a const class pointer can be used.
    22 //				  * MakeDelegate() global helper function added to simplify pass-by-value.
    23 //				  * Added fastdelegate.clear()
    24 // 16-Jul-04 1.2.1* Workaround for gcc bug (const member function pointers in templates)
    25 // 30-Oct-04 1.3  * Support for (non-void) return values.
    26 //				  * No more workarounds in client code!
    27 //					 MSVC and Intel now use a clever hack invented by John Dlugosz:
    28 //				     - The FASTDELEGATEDECLARE workaround is no longer necessary.
    29 //					 - No more warning messages for VC6
    30 //				  * Less use of macros. Error messages should be more comprehensible.
    31 //				  * Added include guards
    32 //				  * Added FastDelegate::empty() to test if invocation is safe (Thanks Neville Franks).
    33 //				  * Now tested on VS 2005 Beta, PGI C++
    34 // 24-Dec-04 1.4  * Added DelegateMemento, to allow collections of disparate delegates.
    35 //                * <,>,<=,>= comparison operators to allow storage in ordered containers.
    36 //				  * Substantial reduction of code size, especially the 'Closure' class.
    37 //				  * Standardised all the compiler-specific workarounds.
    38 //                * MFP conversion now works for CodePlay (but not yet supported in the full code).
    39 //                * Now compiles without warnings on _any_ compiler, including BCC 5.5.1
    40 //				  * New syntax: FastDelegate< int (char *, double) >. 
    41 
    42 #ifndef FASTDELEGATE_H
    43 #define FASTDELEGATE_H
    44 
    45 #ifdef _MSC_VER
    46 # if _MSC_VER > 1000
    47 #  pragma once
    48 # endif // _MSC_VER > 1000
    49 #endif // #ifdef _MSC_VER
    50 
    51 #include <memory.h> // to allow <,> comparisons
    52 
    53 ////////////////////////////////////////////////////////////////////////////////
    54 //						Configuration options
    55 //
    56 ////////////////////////////////////////////////////////////////////////////////
    57 
    58 // Uncomment the following #define for optimally-sized delegates.
    59 // In this case, the generated asm code is almost identical to the code you'd get
    60 // if the compiler had native support for delegates.
    61 // It will not work on systems where sizeof(dataptr) < sizeof(codeptr). 
    62 // Thus, it will not work for DOS compilers using the medium model.
    63 // It will also probably fail on some DSP systems.
    64 #define FASTDELEGATE_USESTATICFUNCTIONHACK
    65 
    66 // Uncomment the next line to allow function declarator syntax.
    67 // It is automatically enabled for those compilers where it is known to work.
    68 //#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
    69 
    70 ////////////////////////////////////////////////////////////////////////////////
    71 //						Compiler identification for workarounds
    72 //
    73 ////////////////////////////////////////////////////////////////////////////////
    74 
    75 // Compiler identification. It's not easy to identify Visual C++ because
    76 // many vendors fraudulently define Microsoft's identifiers.
    77 #if defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__VECTOR_C) && !defined(__ICL) && !defined(__BORLANDC__)
    78 #define FASTDLGT_ISMSVC
    79 
    80 #if (_MSC_VER <1300) // Many workarounds are required for VC6.
    81 #define FASTDLGT_VC6
    82 #pragma warning(disable:4786) // disable this ridiculous warning
    83 #endif
    84 
    85 #endif
    86 
    87 // Does the compiler uses Microsoft's member function pointer structure?
    88 // If so, it needs special treatment.
    89 // Metrowerks CodeWarrior, Intel, and CodePlay fraudulently define Microsoft's 
    90 // identifier, _MSC_VER. We need to filter Metrowerks out.
    91 #if defined(_MSC_VER) && !defined(__MWERKS__)
    92 #define FASTDLGT_MICROSOFT_MFP
    93 
    94 #if !defined(__VECTOR_C)
    95 // CodePlay doesn't have the __single/multi/virtual_inheritance keywords
    96 #define FASTDLGT_HASINHERITANCE_KEYWORDS
    97 #endif
    98 #endif
    99 
   100 // Does it allow function declarator syntax? The following compilers are known to work:
   101 #if defined(FASTDLGT_ISMSVC) && (_MSC_VER >=1310) // VC 7.1
   102 #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
   103 #endif
   104 
   105 // Gcc(2.95+), and versions of Digital Mars, Intel and Comeau in common use.
   106 #if defined (__DMC__) || defined(__GNUC__) || defined(__ICL) || defined(__COMO__)
   107 #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
   108 #endif
   109 
   110 // It works on Metrowerks MWCC 3.2.2. From boost.Config it should work on earlier ones too.
   111 #if defined (__MWERKS__)
   112 #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
   113 #endif
   114 
   115 #ifdef __GNUC__ // Workaround GCC bug #8271 
   116 	// At present, GCC doesn't recognize constness of MFPs in templates
   117 #define FASTDELEGATE_GCC_BUG_8271
   118 #endif
   119 
   120 
   121 
   122 ////////////////////////////////////////////////////////////////////////////////
   123 //						General tricks used in this code
   124 //
   125 // (a) Error messages are generated by typdefing an array of negative size to
   126 //     generate compile-time errors.
   127 // (b) Warning messages on MSVC are generated by declaring unused variables, and
   128 //	    enabling the "variable XXX is never used" warning.
   129 // (c) Unions are used in a few compiler-specific cases to perform illegal casts.
   130 // (d) For Microsoft and Intel, when adjusting the 'this' pointer, it's cast to
   131 //     (char *) first to ensure that the correct number of *bytes* are added.
   132 //
   133 ////////////////////////////////////////////////////////////////////////////////
   134 //						Helper templates
   135 //
   136 ////////////////////////////////////////////////////////////////////////////////
   137 
   138 
   139 namespace fastdelegate {
   140 namespace detail {	// we'll hide the implementation details in a nested namespace.
   141 
   142 //		implicit_cast< >
   143 // I believe this was originally going to be in the C++ standard but 
   144 // was left out by accident. It's even milder than static_cast.
   145 // I use it instead of static_cast<> to emphasize that I'm not doing
   146 // anything nasty. 
   147 // Usage is identical to static_cast<>
   148 template <class OutputClass, class InputClass>
   149 inline OutputClass implicit_cast(InputClass input){
   150 	return input;
   151 }
   152 
   153 //		horrible_cast< >
   154 // This is truly evil. It completely subverts C++'s type system, allowing you 
   155 // to cast from any class to any other class. Technically, using a union 
   156 // to perform the cast is undefined behaviour (even in C). But we can see if
   157 // it is OK by checking that the union is the same size as each of its members.
   158 // horrible_cast<> should only be used for compiler-specific workarounds. 
   159 // Usage is identical to reinterpret_cast<>.
   160 
   161 // This union is declared outside the horrible_cast because BCC 5.5.1
   162 // can't inline a function with a nested class, and gives a warning.
   163 template <class OutputClass, class InputClass>
   164 union horrible_union{
   165 	OutputClass out;
   166 	InputClass in;
   167 };
   168 
   169 template <class OutputClass, class InputClass>
   170 inline OutputClass horrible_cast(const InputClass input){
   171 	horrible_union<OutputClass, InputClass> u;
   172 	// Cause a compile-time error if in, out and u are not the same size.
   173 	// If the compile fails here, it means the compiler has peculiar
   174 	// unions which would prevent the cast from working.
   175 	typedef int ERROR_CantUseHorrible_cast[sizeof(InputClass)==sizeof(u) 
   176 		&& sizeof(InputClass)==sizeof(OutputClass) ? 1 : -1];
   177 	u.in = input;
   178 	return u.out;
   179 }
   180 
   181 ////////////////////////////////////////////////////////////////////////////////
   182 //						Workarounds
   183 //
   184 ////////////////////////////////////////////////////////////////////////////////
   185 
   186 // Backwards compatibility: This macro used to be necessary in the virtual inheritance
   187 // case for Intel and Microsoft. Now it just forward-declares the class.
   188 #define FASTDELEGATEDECLARE(CLASSNAME)	class CLASSNAME;
   189 
   190 // Prevent use of the static function hack with the DOS medium model.
   191 #ifdef __MEDIUM__
   192 #undef FASTDELEGATE_USESTATICFUNCTIONHACK
   193 #endif
   194 
   195 //			DefaultVoid - a workaround for 'void' templates in VC6.
   196 //
   197 //  (1) VC6 and earlier do not allow 'void' as a default template argument.
   198 //  (2) They also doesn't allow you to return 'void' from a function.
   199 //
   200 // Workaround for (1): Declare a dummy type 'DefaultVoid' which we use
   201 //   when we'd like to use 'void'. We convert it into 'void' and back
   202 //   using the templates DefaultVoidToVoid<> and VoidToDefaultVoid<>.
   203 // Workaround for (2): On VC6, the code for calling a void function is
   204 //   identical to the code for calling a non-void function in which the
   205 //   return value is never used, provided the return value is returned
   206 //   in the EAX register, rather than on the stack. 
   207 //   This is true for most fundamental types such as int, enum, void *.
   208 //   Const void * is the safest option since it doesn't participate 
   209 //   in any automatic conversions. But on a 16-bit compiler it might
   210 //   cause extra code to be generated, so we disable it for all compilers
   211 //   except for VC6 (and VC5).
   212 #ifdef FASTDLGT_VC6
   213 // VC6 workaround
   214 typedef const void * DefaultVoid;
   215 #else
   216 // On any other compiler, just use a normal void.
   217 typedef void DefaultVoid;
   218 #endif
   219 
   220 // Translate from 'DefaultVoid' to 'void'.
   221 // Everything else is unchanged
   222 template <class T>
   223 struct DefaultVoidToVoid { typedef T type; };
   224 
   225 template <>
   226 struct DefaultVoidToVoid<DefaultVoid> {	typedef void type; };
   227 
   228 // Translate from 'void' into 'DefaultVoid'
   229 // Everything else is unchanged
   230 template <class T>
   231 struct VoidToDefaultVoid { typedef T type; };
   232 
   233 template <>
   234 struct VoidToDefaultVoid<void> { typedef DefaultVoid type; };
   235 
   236 
   237 
   238 ////////////////////////////////////////////////////////////////////////////////
   239 //						Fast Delegates, part 1:
   240 //
   241 //		Conversion of member function pointer to a standard form
   242 //
   243 ////////////////////////////////////////////////////////////////////////////////
   244 
   245 // GenericClass is a fake class, ONLY used to provide a type.
   246 // It is vitally important that it is never defined, so that the compiler doesn't
   247 // think it can optimize the invocation. For example, Borland generates simpler
   248 // code if it knows the class only uses single inheritance.
   249 
   250 // Compilers using Microsoft's structure need to be treated as a special case.
   251 #ifdef  FASTDLGT_MICROSOFT_MFP
   252 
   253 #ifdef FASTDLGT_HASINHERITANCE_KEYWORDS
   254 	// For Microsoft and Intel, we want to ensure that it's the most efficient type of MFP 
   255 	// (4 bytes), even when the /vmg option is used. Declaring an empty class 
   256 	// would give 16 byte pointers in this case....
   257 	class __single_inheritance GenericClass;
   258 #endif
   259 	// ...but for Codeplay, an empty class *always* gives 4 byte pointers.
   260 	// If compiled with the /clr option ("managed C++"), the JIT compiler thinks
   261 	// it needs to load GenericClass before it can call any of its functions,
   262 	// (compiles OK but crashes at runtime!), so we need to declare an 
   263 	// empty class to make it happy.
   264 	// Codeplay and VC4 can't cope with the unknown_inheritance case either.
   265 	class GenericClass {};
   266 #else
   267 	class GenericClass;
   268 #endif
   269 
   270 // The size of a single inheritance member function pointer.
   271 const int SINGLE_MEMFUNCPTR_SIZE = sizeof(void (GenericClass::*)());
   272 
   273 //						SimplifyMemFunc< >::Convert()
   274 //
   275 //	A template function that converts an arbitrary member function pointer into the 
   276 //	simplest possible form of member function pointer, using a supplied 'this' pointer.
   277 //  According to the standard, this can be done legally with reinterpret_cast<>.
   278 //	For (non-standard) compilers which use member function pointers which vary in size 
   279 //  depending on the class, we need to use	knowledge of the internal structure of a 
   280 //  member function pointer, as used by the compiler. Template specialization is used
   281 //  to distinguish between the sizes. Because some compilers don't support partial 
   282 //	template specialisation, I use full specialisation of a wrapper struct.
   283 
   284 // general case -- don't know how to convert it. Force a compile failure
   285 template <int N>
   286 struct SimplifyMemFunc {
   287 	template <class X, class XFuncType, class GenericMemFuncType>
   288 	inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, 
   289 		GenericMemFuncType &bound_func) { 
   290 		// Unsupported member function type -- force a compile failure.
   291 	    // (it's illegal to have a array with negative size).
   292 		typedef char ERROR_Unsupported_member_function_pointer_on_this_compiler[N-100];
   293 		return 0; 
   294 	}
   295 };
   296 
   297 // For compilers where all member func ptrs are the same size, everything goes here.
   298 // For non-standard compilers, only single_inheritance classes go here.
   299 template <>
   300 struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE>  {	
   301 	template <class X, class XFuncType, class GenericMemFuncType>
   302 	inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, 
   303 			GenericMemFuncType &bound_func) {
   304 #if defined __DMC__  
   305 		// Digital Mars doesn't allow you to cast between abitrary PMF's, 
   306 		// even though the standard says you can. The 32-bit compiler lets you
   307 		// static_cast through an int, but the DOS compiler doesn't.
   308 		bound_func = horrible_cast<GenericMemFuncType>(function_to_bind);
   309 #else 
   310         bound_func = reinterpret_cast<GenericMemFuncType>(function_to_bind);
   311 #endif
   312         return reinterpret_cast<GenericClass *>(pthis);
   313 	}
   314 };
   315 
   316 ////////////////////////////////////////////////////////////////////////////////
   317 //						Fast Delegates, part 1b:
   318 //
   319 //					Workarounds for Microsoft and Intel
   320 //
   321 ////////////////////////////////////////////////////////////////////////////////
   322 
   323 
   324 // Compilers with member function pointers which violate the standard (MSVC, Intel, Codeplay),
   325 // need to be treated as a special case.
   326 #ifdef FASTDLGT_MICROSOFT_MFP
   327 
   328 // We use unions to perform horrible_casts. I would like to use #pragma pack(push, 1)
   329 // at the start of each function for extra safety, but VC6 seems to ICE
   330 // intermittently if you do this inside a template.
   331 
   332 // __multiple_inheritance classes go here
   333 // Nasty hack for Microsoft and Intel (IA32 and Itanium)
   334 template<>
   335 struct SimplifyMemFunc< SINGLE_MEMFUNCPTR_SIZE + sizeof(int) >  {
   336 	template <class X, class XFuncType, class GenericMemFuncType>
   337 	inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, 
   338 		GenericMemFuncType &bound_func) { 
   339 		// We need to use a horrible_cast to do this conversion.
   340 		// In MSVC, a multiple inheritance member pointer is internally defined as:
   341         union {
   342 			XFuncType func;
   343 			struct {	 
   344 				GenericMemFuncType funcaddress; // points to the actual member function
   345 				int delta;	     // #BYTES to be added to the 'this' pointer
   346 			}s;
   347         } u;
   348 		// Check that the horrible_cast will work
   349 		typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s)? 1 : -1];
   350         u.func = function_to_bind;
   351 		bound_func = u.s.funcaddress;
   352 		return reinterpret_cast<GenericClass *>(reinterpret_cast<char *>(pthis) + u.s.delta); 
   353 	}
   354 };
   355 
   356 // virtual inheritance is a real nuisance. It's inefficient and complicated.
   357 // On MSVC and Intel, there isn't enough information in the pointer itself to
   358 // enable conversion to a closure pointer. Earlier versions of this code didn't
   359 // work for all cases, and generated a compile-time error instead.
   360 // But a very clever hack invented by John M. Dlugosz solves this problem.
   361 // My code is somewhat different to his: I have no asm code, and I make no 
   362 // assumptions about the calling convention that is used.
   363 
   364 // In VC++ and ICL, a virtual_inheritance member pointer 
   365 // is internally defined as:
   366 struct MicrosoftVirtualMFP {
   367 	void (GenericClass::*codeptr)(); // points to the actual member function
   368 	int delta;		// #bytes to be added to the 'this' pointer
   369 	int vtable_index; // or 0 if no virtual inheritance
   370 };
   371 // The CRUCIAL feature of Microsoft/Intel MFPs which we exploit is that the
   372 // m_codeptr member is *always* called, regardless of the values of the other
   373 // members. (This is *not* true for other compilers, eg GCC, which obtain the
   374 // function address from the vtable if a virtual function is being called).
   375 // Dlugosz's trick is to make the codeptr point to a probe function which
   376 // returns the 'this' pointer that was used.
   377 
   378 // Define a generic class that uses virtual inheritance.
   379 // It has a trival member function that returns the value of the 'this' pointer.
   380 struct GenericVirtualClass : virtual public GenericClass
   381 {
   382 	typedef GenericVirtualClass * (GenericVirtualClass::*ProbePtrType)();
   383 	GenericVirtualClass * GetThis() { return this; }
   384 };
   385 
   386 // __virtual_inheritance classes go here
   387 template <>
   388 struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 2*sizeof(int) >
   389 {
   390 
   391 	template <class X, class XFuncType, class GenericMemFuncType>
   392 	inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, 
   393 		GenericMemFuncType &bound_func) {
   394 		union {
   395 			XFuncType func;
   396 			GenericClass* (X::*ProbeFunc)();
   397 			MicrosoftVirtualMFP s;
   398 		} u;
   399 		u.func = function_to_bind;
   400 		bound_func = reinterpret_cast<GenericMemFuncType>(u.s.codeptr);
   401 		union {
   402 			GenericVirtualClass::ProbePtrType virtfunc;
   403 			MicrosoftVirtualMFP s;
   404 		} u2;
   405 		// Check that the horrible_cast<>s will work
   406 		typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s)
   407 			&& sizeof(function_to_bind)==sizeof(u.ProbeFunc)
   408 			&& sizeof(u2.virtfunc)==sizeof(u2.s) ? 1 : -1];
   409    // Unfortunately, taking the address of a MF prevents it from being inlined, so 
   410    // this next line can't be completely optimised away by the compiler.
   411 		u2.virtfunc = &GenericVirtualClass::GetThis;
   412 		u.s.codeptr = u2.s.codeptr;
   413 		return (pthis->*u.ProbeFunc)();
   414 	}
   415 };
   416 
   417 #if (_MSC_VER <1300)
   418 
   419 // Nasty hack for Microsoft Visual C++ 6.0
   420 // unknown_inheritance classes go here
   421 // There is a compiler bug in MSVC6 which generates incorrect code in this case!!
   422 template <>
   423 struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(int) >
   424 {
   425 	template <class X, class XFuncType, class GenericMemFuncType>
   426 	inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, 
   427 		GenericMemFuncType &bound_func) {
   428 		// There is an apalling but obscure compiler bug in MSVC6 and earlier:
   429 		// vtable_index and 'vtordisp' are always set to 0 in the 
   430 		// unknown_inheritance case!
   431 		// This means that an incorrect function could be called!!!
   432 		// Compiling with the /vmg option leads to potentially incorrect code.
   433 		// This is probably the reason that the IDE has a user interface for specifying
   434 		// the /vmg option, but it is disabled -  you can only specify /vmg on 
   435 		// the command line. In VC1.5 and earlier, the compiler would ICE if it ever
   436 		// encountered this situation.
   437 		// It is OK to use the /vmg option if /vmm or /vms is specified.
   438 
   439 		// Fortunately, the wrong function is only called in very obscure cases.
   440 		// It only occurs when a derived class overrides a virtual function declared 
   441 		// in a virtual base class, and the member function 
   442 		// points to the *Derived* version of that function. The problem can be
   443 		// completely averted in 100% of cases by using the *Base class* for the 
   444 		// member fpointer. Ie, if you use the base class as an interface, you'll
   445 		// stay out of trouble.
   446 		// Occasionally, you might want to point directly to a derived class function
   447 		// that isn't an override of a base class. In this case, both vtable_index 
   448 		// and 'vtordisp' are zero, but a virtual_inheritance pointer will be generated.
   449 		// We can generate correct code in this case. To prevent an incorrect call from
   450 		// ever being made, on MSVC6 we generate a warning, and call a function to 
   451 		// make the program crash instantly. 
   452 		typedef char ERROR_VC6CompilerBug[-100];
   453 		return 0; 
   454 	}
   455 };
   456 
   457 
   458 #else 
   459 
   460 // Nasty hack for Microsoft and Intel (IA32 and Itanium)
   461 // unknown_inheritance classes go here 
   462 // This is probably the ugliest bit of code I've ever written. Look at the casts!
   463 // There is a compiler bug in MSVC6 which prevents it from using this code.
   464 template <>
   465 struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(int) >
   466 {
   467 	template <class X, class XFuncType, class GenericMemFuncType>
   468 	inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, 
   469 			GenericMemFuncType &bound_func) {
   470 		// The member function pointer is 16 bytes long. We can't use a normal cast, but
   471 		// we can use a union to do the conversion.
   472 		union {
   473 			XFuncType func;
   474 			// In VC++ and ICL, an unknown_inheritance member pointer 
   475 			// is internally defined as:
   476 			struct {
   477 				GenericMemFuncType m_funcaddress; // points to the actual member function
   478 				int delta;		// #bytes to be added to the 'this' pointer
   479 				int vtordisp;		// #bytes to add to 'this' to find the vtable
   480 				int vtable_index; // or 0 if no virtual inheritance
   481 			} s;
   482 		} u;
   483 		// Check that the horrible_cast will work
   484 		typedef int ERROR_CantUsehorrible_cast[sizeof(XFuncType)==sizeof(u.s)? 1 : -1];
   485 		u.func = function_to_bind;
   486 		bound_func = u.s.funcaddress;
   487 		int virtual_delta = 0;
   488 		if (u.s.vtable_index) { // Virtual inheritance is used
   489 			// First, get to the vtable. 
   490 			// It is 'vtordisp' bytes from the start of the class.
   491 			const int * vtable = *reinterpret_cast<const int *const*>(
   492 				reinterpret_cast<const char *>(pthis) + u.s.vtordisp );
   493 
   494 			// 'vtable_index' tells us where in the table we should be looking.
   495 			virtual_delta = u.s.vtordisp + *reinterpret_cast<const int *>( 
   496 				reinterpret_cast<const char *>(vtable) + u.s.vtable_index);
   497 		}
   498 		// The int at 'virtual_delta' gives us the amount to add to 'this'.
   499         // Finally we can add the three components together. Phew!
   500         return reinterpret_cast<GenericClass *>(
   501 			reinterpret_cast<char *>(pthis) + u.s.delta + virtual_delta);
   502 	};
   503 };
   504 #endif // MSVC 7 and greater
   505 
   506 #endif // MS/Intel hacks
   507 
   508 }  // namespace detail
   509 
   510 ////////////////////////////////////////////////////////////////////////////////
   511 //						Fast Delegates, part 2:
   512 //
   513 //	Define the delegate storage, and cope with static functions
   514 //
   515 ////////////////////////////////////////////////////////////////////////////////
   516 
   517 // DelegateMemento -- an opaque structure which can hold an arbitary delegate.
   518 // It knows nothing about the calling convention or number of arguments used by
   519 // the function pointed to.
   520 // It supplies comparison operators so that it can be stored in STL collections.
   521 // It cannot be set to anything other than null, nor invoked directly: 
   522 //   it must be converted to a specific delegate.
   523 
   524 // Implementation:
   525 // There are two possible implementations: the Safe method and the Evil method.
   526 //				DelegateMemento - Safe version
   527 //
   528 // This implementation is standard-compliant, but a bit tricky.
   529 // A static function pointer is stored inside the class. 
   530 // Here are the valid values:
   531 // +-- Static pointer --+--pThis --+-- pMemFunc-+-- Meaning------+
   532 // |   0				|  0       |   0        | Empty          |
   533 // |   !=0              |(dontcare)|  Invoker   | Static function|
   534 // |   0                |  !=0     |  !=0       | Method call    |
   535 // +--------------------+----------+------------+----------------+
   536 // When stored stored inside a specific delegate, the 'dontcare' entries are replaced
   537 // with a reference to the delegate itself. This complicates the = and == operators
   538 // for the delegate class.
   539 
   540 //				DelegateMemento - Evil version
   541 //
   542 // For compilers where data pointers are at least as big as code pointers, it is 
   543 // possible to store the function pointer in the this pointer, using another 
   544 // horrible_cast. In this case the DelegateMemento implementation is simple:
   545 // +--pThis --+-- pMemFunc-+-- Meaning---------------------+
   546 // |    0     |  0         | Empty                         |
   547 // |  !=0     |  !=0       | Static function or method call|
   548 // +----------+------------+-------------------------------+
   549 // Note that the Sun C++ and MSVC documentation explicitly state that they 
   550 // support static_cast between void * and function pointers.
   551 
   552 class DelegateMemento {
   553 protected: 
   554 	// the data is protected, not private, because many
   555 	// compilers have problems with template friends.
   556 	typedef void (detail::GenericClass::*GenericMemFuncType)(); // arbitrary MFP.
   557 	detail::GenericClass *m_pthis;
   558 	GenericMemFuncType m_pFunction;
   559 
   560 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   561 	typedef void (*GenericFuncPtr)(); // arbitrary code pointer
   562 	GenericFuncPtr m_pStaticFunction;
   563 #endif
   564 
   565 public:
   566 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   567 	DelegateMemento() : m_pthis(0), m_pFunction(0), m_pStaticFunction(0) {};
   568 	void clear() {
   569 		m_pthis=0; m_pFunction=0; m_pStaticFunction=0;
   570 	}
   571 #else
   572 	DelegateMemento() : m_pthis(0), m_pFunction(0) {};
   573 	void clear() {
   574 		m_pthis=0; m_pFunction=0;
   575 	}
   576 #endif
   577 public:
   578 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   579 	inline bool IsEqual (const DelegateMemento &x) const{
   580 	    // We have to cope with the static function pointers as a special case
   581 		if (m_pFunction!=x.m_pFunction) return false;
   582 		// the static function ptrs must either both be equal, or both be 0.
   583 		if (m_pStaticFunction!=x.m_pStaticFunction) return false;
   584 		if (m_pStaticFunction!=0) return m_pthis==x.m_pthis;
   585 		else return true;
   586 	}
   587 #else // Evil Method
   588 	inline bool IsEqual (const DelegateMemento &x) const{
   589 		return m_pthis==x.m_pthis && m_pFunction==x.m_pFunction;
   590 	}
   591 #endif
   592 	// Provide a strict weak ordering for DelegateMementos.
   593 	inline bool IsLess(const DelegateMemento &right) const {
   594 		// deal with static function pointers first
   595 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   596 		if (m_pStaticFunction !=0 || right.m_pStaticFunction!=0) 
   597 				return m_pStaticFunction < right.m_pStaticFunction;
   598 #endif
   599 		if (m_pthis !=right.m_pthis) return m_pthis < right.m_pthis;
   600 	// There are no ordering operators for member function pointers, 
   601 	// but we can fake one by comparing each byte. The resulting ordering is
   602 	// arbitrary (and compiler-dependent), but it permits storage in ordered STL containers.
   603 		return memcmp(&m_pFunction, &right.m_pFunction, sizeof(m_pFunction)) < 0;
   604 
   605 	}
   606 	inline bool operator ! () const		// Is it bound to anything?
   607 	{ return m_pFunction==0; }
   608 public:
   609 	DelegateMemento & operator = (const DelegateMemento &right)  {
   610 		SetMementoFrom(right); 
   611 		return *this;
   612 	}
   613 	inline bool operator <(const DelegateMemento &right) {
   614 		return IsLess(right);
   615 	}
   616 	inline bool operator >(const DelegateMemento &right) {
   617 		return right.IsLess(*this);
   618 	}
   619 	DelegateMemento (const DelegateMemento &right)  : 
   620 		m_pthis(right.m_pthis), m_pFunction(right.m_pFunction)   
   621 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   622 		, m_pStaticFunction (right.m_pStaticFunction)
   623 #endif
   624 		{}
   625 protected:
   626 	void SetMementoFrom(const DelegateMemento &right)  {
   627 		m_pFunction = right.m_pFunction;
   628 		m_pthis = right.m_pthis;
   629 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   630 		m_pStaticFunction = right.m_pStaticFunction;
   631 #endif
   632 	}
   633 };
   634 
   635 
   636 //						ClosurePtr<>
   637 //
   638 // A private wrapper class that adds function signatures to DelegateMemento.
   639 // It's the class that does most of the actual work.
   640 // The signatures are specified by:
   641 // GenericMemFunc: must be a type of GenericClass member function pointer. 
   642 // StaticFuncPtr:  must be a type of function pointer with the same signature 
   643 //                 as GenericMemFunc.
   644 // UnvoidStaticFuncPtr: is the same as StaticFuncPtr, except on VC6
   645 //                 where it never returns void (returns DefaultVoid instead).
   646 
   647 // An outer class, FastDelegateN<>, handles the invoking and creates the
   648 // necessary typedefs.
   649 // This class does everything else.
   650 
   651 namespace detail {
   652 
   653 template < class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
   654 class ClosurePtr : public DelegateMemento {
   655 public:
   656 	// These functions are for setting the delegate to a member function.
   657 
   658 	// Here's the clever bit: we convert an arbitrary member function into a 
   659 	// standard form. XMemFunc should be a member function of class X, but I can't 
   660 	// enforce that here. It needs to be enforced by the wrapper class.
   661 	template < class X, class XMemFunc >
   662 	inline void bindmemfunc(X *pthis, XMemFunc function_to_bind ) {
   663 		m_pthis = SimplifyMemFunc< sizeof(function_to_bind) >
   664 			::Convert(pthis, function_to_bind, m_pFunction);
   665 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   666 		m_pStaticFunction = 0;
   667 #endif
   668 	}
   669 	// For const member functions, we only need a const class pointer.
   670 	// Since we know that the member function is const, it's safe to 
   671 	// remove the const qualifier from the 'this' pointer with a const_cast.
   672 	// VC6 has problems if we just overload 'bindmemfunc', so we give it a different name.
   673 	template < class X, class XMemFunc>
   674 	inline void bindconstmemfunc(const X *pthis, XMemFunc function_to_bind) {
   675 		m_pthis= SimplifyMemFunc< sizeof(function_to_bind) >
   676 			::Convert(const_cast<X*>(pthis), function_to_bind, m_pFunction);
   677 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   678 		m_pStaticFunction = 0;
   679 #endif
   680 	}
   681 #ifdef FASTDELEGATE_GCC_BUG_8271	// At present, GCC doesn't recognize constness of MFPs in templates
   682 	template < class X, class XMemFunc>
   683 	inline void bindmemfunc(const X *pthis, XMemFunc function_to_bind) {
   684 		bindconstmemfunc(pthis, function_to_bind);
   685 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   686 		m_pStaticFunction = 0;
   687 #endif
   688 	}
   689 #endif
   690 	// These functions are required for invoking the stored function
   691 	inline GenericClass *GetClosureThis() const { return m_pthis; }
   692 	inline GenericMemFunc GetClosureMemPtr() const { return reinterpret_cast<GenericMemFunc>(m_pFunction); }
   693 
   694 // There are a few ways of dealing with static function pointers.
   695 // There's a standard-compliant, but tricky method.
   696 // There's also a straightforward hack, that won't work on DOS compilers using the
   697 // medium memory model. It's so evil that I can't recommend it, but I've
   698 // implemented it anyway because it produces very nice asm code.
   699 
   700 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   701 
   702 //				ClosurePtr<> - Safe version
   703 //
   704 // This implementation is standard-compliant, but a bit tricky.
   705 // I store the function pointer inside the class, and the delegate then
   706 // points to itself. Whenever the delegate is copied, these self-references
   707 // must be transformed, and this complicates the = and == operators.
   708 public:
   709 	// The next two functions are for operator ==, =, and the copy constructor.
   710 	// We may need to convert the m_pthis pointers, so that
   711 	// they remain as self-references.
   712 	template< class DerivedClass >
   713 	inline void CopyFrom (DerivedClass *pParent, const DelegateMemento &x) {
   714 		SetMementoFrom(x);
   715 		if (m_pStaticFunction!=0) {
   716 			// transform self references...
   717 			m_pthis=reinterpret_cast<GenericClass *>(pParent);
   718 		}
   719 	}
   720 	// For static functions, the 'static_function_invoker' class in the parent 
   721 	// will be called. The parent then needs to call GetStaticFunction() to find out 
   722 	// the actual function to invoke.
   723 	template < class DerivedClass, class ParentInvokerSig >
   724 	inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker, 
   725 				StaticFuncPtr function_to_bind ) {
   726 		bindmemfunc(pParent, static_function_invoker);
   727 		m_pStaticFunction=reinterpret_cast<GenericFuncPtr>(function_to_bind);
   728 	}
   729 	inline UnvoidStaticFuncPtr GetStaticFunction() const { 
   730 		return reinterpret_cast<UnvoidStaticFuncPtr>(m_pStaticFunction); 
   731 	}
   732 #else
   733 
   734 //				ClosurePtr<> - Evil version
   735 //
   736 // For compilers where data pointers are at least as big as code pointers, it is 
   737 // possible to store the function pointer in the this pointer, using another 
   738 // horrible_cast. Invocation isn't any faster, but it saves 4 bytes, and
   739 // speeds up comparison and assignment. If C++ provided direct language support
   740 // for delegates, they would produce asm code that was almost identical to this.
   741 // Note that the Sun C++ and MSVC documentation explicitly state that they 
   742 // support static_cast between void * and function pointers.
   743 
   744 	template< class DerivedClass >
   745 	inline void CopyFrom (DerivedClass *pParent, const DelegateMemento &right) {
   746 		SetMementoFrom(right);
   747 	}
   748 	// For static functions, the 'static_function_invoker' class in the parent 
   749 	// will be called. The parent then needs to call GetStaticFunction() to find out 
   750 	// the actual function to invoke.
   751 	// ******** EVIL, EVIL CODE! *******
   752 	template < 	class DerivedClass, class ParentInvokerSig>
   753 	inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker, 
   754 				StaticFuncPtr function_to_bind) {
   755 		// We'll be ignoring the 'this' pointer, but we need to make sure we pass
   756 		// a valid value to bindmemfunc().
   757 		bindmemfunc(pParent, static_function_invoker);
   758 
   759 		// WARNING! Evil hack. We store the function in the 'this' pointer!
   760 		// Ensure that there's a compilation failure if function pointers 
   761 		// and data pointers have different sizes.
   762 		// If you get this error, you need to #undef FASTDELEGATE_USESTATICFUNCTIONHACK.
   763 		typedef int ERROR_CantUseEvilMethod[sizeof(GenericClass *)==sizeof(function_to_bind) ? 1 : -1];
   764 		m_pthis = horrible_cast<GenericClass *>(function_to_bind);
   765 		// MSVC, SunC++ and DMC accept the following (non-standard) code:
   766 //		m_pthis = static_cast<GenericClass *>(static_cast<void *>(function_to_bind));
   767 		// BCC32, Comeau and DMC accept this method. MSVC7.1 needs __int64 instead of long
   768 //		m_pthis = reinterpret_cast<GenericClass *>(reinterpret_cast<long>(function_to_bind));
   769 	}
   770 	// ******** EVIL, EVIL CODE! *******
   771 	// This function will be called with an invalid 'this' pointer!!
   772 	// We're just returning the 'this' pointer, converted into
   773 	// a function pointer!
   774 	inline UnvoidStaticFuncPtr GetStaticFunction() const {
   775 		// Ensure that there's a compilation failure if function pointers 
   776 		// and data pointers have different sizes.
   777 		// If you get this error, you need to #undef FASTDELEGATE_USESTATICFUNCTIONHACK.
   778 		typedef int ERROR_CantUseEvilMethod[sizeof(UnvoidStaticFuncPtr)==sizeof(this) ? 1 : -1];
   779 		return horrible_cast<UnvoidStaticFuncPtr>(this);
   780 	}
   781 #endif // !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
   782 
   783 };
   784 
   785 
   786 } // namespace detail
   787 
   788 ////////////////////////////////////////////////////////////////////////////////
   789 //						Fast Delegates, part 3:
   790 //
   791 //				Wrapper classes to ensure type safety
   792 //
   793 ////////////////////////////////////////////////////////////////////////////////
   794 
   795 
   796 // Once we have the member function conversion templates, it's easy to make the
   797 // wrapper classes. So that they will work with as many compilers as possible, 
   798 // the classes are of the form
   799 //   FastDelegate3<int, char *, double>
   800 // They can cope with any combination of parameters. The max number of parameters
   801 // allowed is 8, but it is trivial to increase this limit.
   802 // Note that we need to treat const member functions seperately.
   803 // All this class does is to enforce type safety, and invoke the delegate with
   804 // the correct list of parameters.
   805 
   806 // Because of the weird rule about the class of derived member function pointers,
   807 // you sometimes need to apply a downcast to the 'this' pointer.
   808 // This is the reason for the use of "implicit_cast<X*>(pthis)" in the code below. 
   809 // If CDerivedClass is derived from CBaseClass, but doesn't override SimpleVirtualFunction,
   810 // without this trick you'd need to write:
   811 //		MyDelegate(static_cast<CBaseClass *>(&d), &CDerivedClass::SimpleVirtualFunction);
   812 // but with the trick you can write
   813 //		MyDelegate(&d, &CDerivedClass::SimpleVirtualFunction);
   814 
   815 // RetType is the type the compiler uses in compiling the template. For VC6,
   816 // it cannot be void. DesiredRetType is the real type which is returned from
   817 // all of the functions. It can be void.
   818 
   819 //N=0
   820 template<class RetType=detail::DefaultVoid>
   821 class FastDelegate0 {
   822 private:
   823 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
   824 	typedef DesiredRetType (*StaticFunctionPtr)();
   825 	typedef RetType (*UnvoidStaticFunctionPtr)();
   826 	typedef RetType (detail::GenericClass::*GenericMemFn)();
   827 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
   828 public:
   829 	// Typedefs to aid generic programming
   830 	typedef FastDelegate0 type;
   831 
   832 	// Construction and comparison functions
   833 	FastDelegate0() { clear(); }
   834 	FastDelegate0(const FastDelegate0 &x) {
   835 		m_Closure.CopyFrom(this, x.m_Closure); }
   836 	void operator = (const FastDelegate0 &x)  {
   837 		m_Closure.CopyFrom(this, x.m_Closure); }
   838 	bool operator ==(const FastDelegate0 &x) const {
   839 		return m_Closure.IsEqual(x.m_Closure);	}
   840 	bool operator !=(const FastDelegate0 &x) const {
   841 		return !m_Closure.IsEqual(x.m_Closure); }
   842 	bool operator <(const FastDelegate0 &x) const {
   843 		return m_Closure.IsLess(x.m_Closure);	}
   844 	bool operator >(const FastDelegate0 &x) const {
   845 		return x.m_Closure.IsLess(m_Closure);	}
   846 	// Binding to non-const member functions
   847 	template < class X, class Y >
   848 	FastDelegate0(Y *pthis, DesiredRetType (X::* function_to_bind)() ) {
   849 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
   850 	template < class X, class Y >
   851 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)()) {
   852 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
   853 	// Binding to const member functions.
   854 	template < class X, class Y >
   855 	FastDelegate0(const Y *pthis, DesiredRetType (X::* function_to_bind)() const) {
   856 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
   857 	template < class X, class Y >
   858 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)() const) {
   859 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
   860 	// Static functions. We convert them into a member function call.
   861 	// Note that this also provides a conversion from static functions.
   862 	FastDelegate0(DesiredRetType (*function_to_bind)() ) {
   863 		bind(function_to_bind);	}
   864 	inline void bind(DesiredRetType (*function_to_bind)()) {
   865 		m_Closure.bindstaticfunc(this, &FastDelegate0::InvokeStaticFunction, 
   866 			function_to_bind); }
   867 	RetType operator() () const { // Invoke the delegate
   868 		// this next line is the only one that violates the standard
   869 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(); }
   870 	inline bool operator ! () const	{	// Is it bound to anything?
   871 			return !m_Closure; }
   872 	inline bool empty() const	{
   873 			return !m_Closure; }
   874 	void clear() { m_Closure.clear();}
   875 	// Conversion to and from the DelegateMemento storage class
   876 	const DelegateMemento & GetMemento() { return m_Closure; }
   877 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
   878 
   879 private:	// Invoker for static functions
   880 	RetType InvokeStaticFunction() const {
   881 	return (*(m_Closure.GetStaticFunction()))(); }
   882 };
   883 
   884 //N=1
   885 template<class Param1, class RetType=detail::DefaultVoid>
   886 class FastDelegate1 {
   887 private:
   888 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
   889 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1);
   890 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1);
   891 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1);
   892 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
   893 public:
   894 	// Typedefs to aid generic programming
   895 	typedef FastDelegate1 type;
   896 
   897 	// Construction and comparison functions
   898 	FastDelegate1() { clear(); }
   899 	FastDelegate1(const FastDelegate1 &x) {
   900 		m_Closure.CopyFrom(this, x.m_Closure); }
   901 	void operator = (const FastDelegate1 &x)  {
   902 		m_Closure.CopyFrom(this, x.m_Closure); }
   903 	bool operator ==(const FastDelegate1 &x) const {
   904 		return m_Closure.IsEqual(x.m_Closure);	}
   905 	bool operator !=(const FastDelegate1 &x) const {
   906 		return !m_Closure.IsEqual(x.m_Closure); }
   907 	bool operator <(const FastDelegate1 &x) const {
   908 		return m_Closure.IsLess(x.m_Closure);	}
   909 	bool operator >(const FastDelegate1 &x) const {
   910 		return x.m_Closure.IsLess(m_Closure);	}
   911 	// Binding to non-const member functions
   912 	template < class X, class Y >
   913 	FastDelegate1(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) ) {
   914 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
   915 	template < class X, class Y >
   916 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1)) {
   917 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
   918 	// Binding to const member functions.
   919 	template < class X, class Y >
   920 	FastDelegate1(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) const) {
   921 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
   922 	template < class X, class Y >
   923 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) const) {
   924 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
   925 	// Static functions. We convert them into a member function call.
   926 	// Note that this also provides a conversion from static functions.
   927 	FastDelegate1(DesiredRetType (*function_to_bind)(Param1 p1) ) {
   928 		bind(function_to_bind);	}
   929 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1)) {
   930 		m_Closure.bindstaticfunc(this, &FastDelegate1::InvokeStaticFunction, 
   931 			function_to_bind); }
   932 	RetType operator() (Param1 p1) const { // Invoke the delegate
   933 		// this next line is the only one that violates the standard
   934 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1); }
   935 	inline bool operator ! () const	{	// Is it bound to anything?
   936 			return !m_Closure; }
   937 	inline bool empty() const	{
   938 			return !m_Closure; }
   939 	void clear() { m_Closure.clear();}
   940 	// Conversion to and from the DelegateMemento storage class
   941 	const DelegateMemento & GetMemento() { return m_Closure; }
   942 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
   943 
   944 private:	// Invoker for static functions
   945 	RetType InvokeStaticFunction(Param1 p1) const {
   946 	return (*(m_Closure.GetStaticFunction()))(p1); }
   947 };
   948 
   949 //N=2
   950 template<class Param1, class Param2, class RetType=detail::DefaultVoid>
   951 class FastDelegate2 {
   952 private:
   953 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
   954 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2);
   955 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2);
   956 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2);
   957 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
   958 public:
   959 	// Typedefs to aid generic programming
   960 	typedef FastDelegate2 type;
   961 
   962 	// Construction and comparison functions
   963 	FastDelegate2() { clear(); }
   964 	FastDelegate2(const FastDelegate2 &x) {
   965 		m_Closure.CopyFrom(this, x.m_Closure); }
   966 	void operator = (const FastDelegate2 &x)  {
   967 		m_Closure.CopyFrom(this, x.m_Closure); }
   968 	bool operator ==(const FastDelegate2 &x) const {
   969 		return m_Closure.IsEqual(x.m_Closure);	}
   970 	bool operator !=(const FastDelegate2 &x) const {
   971 		return !m_Closure.IsEqual(x.m_Closure); }
   972 	bool operator <(const FastDelegate2 &x) const {
   973 		return m_Closure.IsLess(x.m_Closure);	}
   974 	bool operator >(const FastDelegate2 &x) const {
   975 		return x.m_Closure.IsLess(m_Closure);	}
   976 	// Binding to non-const member functions
   977 	template < class X, class Y >
   978 	FastDelegate2(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) ) {
   979 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
   980 	template < class X, class Y >
   981 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2)) {
   982 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
   983 	// Binding to const member functions.
   984 	template < class X, class Y >
   985 	FastDelegate2(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) {
   986 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
   987 	template < class X, class Y >
   988 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) {
   989 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
   990 	// Static functions. We convert them into a member function call.
   991 	// Note that this also provides a conversion from static functions.
   992 	FastDelegate2(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) {
   993 		bind(function_to_bind);	}
   994 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2)) {
   995 		m_Closure.bindstaticfunc(this, &FastDelegate2::InvokeStaticFunction, 
   996 			function_to_bind); }
   997 	RetType operator() (Param1 p1, Param2 p2) const { // Invoke the delegate
   998 		// this next line is the only one that violates the standard
   999 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2); }
  1000 	inline bool operator ! () const	{	// Is it bound to anything?
  1001 			return !m_Closure; }
  1002 	inline bool empty() const	{
  1003 			return !m_Closure; }
  1004 	void clear() { m_Closure.clear();}
  1005 	// Conversion to and from the DelegateMemento storage class
  1006 	const DelegateMemento & GetMemento() { return m_Closure; }
  1007 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1008 
  1009 private:	// Invoker for static functions
  1010 	RetType InvokeStaticFunction(Param1 p1, Param2 p2) const {
  1011 	return (*(m_Closure.GetStaticFunction()))(p1, p2); }
  1012 };
  1013 
  1014 //N=3
  1015 template<class Param1, class Param2, class Param3, class RetType=detail::DefaultVoid>
  1016 class FastDelegate3 {
  1017 private:
  1018 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1019 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3);
  1020 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3);
  1021 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3);
  1022 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1023 public:
  1024 	// Typedefs to aid generic programming
  1025 	typedef FastDelegate3 type;
  1026 
  1027 	// Construction and comparison functions
  1028 	FastDelegate3() { clear(); }
  1029 	FastDelegate3(const FastDelegate3 &x) {
  1030 		m_Closure.CopyFrom(this, x.m_Closure); }
  1031 	void operator = (const FastDelegate3 &x)  {
  1032 		m_Closure.CopyFrom(this, x.m_Closure); }
  1033 	bool operator ==(const FastDelegate3 &x) const {
  1034 		return m_Closure.IsEqual(x.m_Closure);	}
  1035 	bool operator !=(const FastDelegate3 &x) const {
  1036 		return !m_Closure.IsEqual(x.m_Closure); }
  1037 	bool operator <(const FastDelegate3 &x) const {
  1038 		return m_Closure.IsLess(x.m_Closure);	}
  1039 	bool operator >(const FastDelegate3 &x) const {
  1040 		return x.m_Closure.IsLess(m_Closure);	}
  1041 	// Binding to non-const member functions
  1042 	template < class X, class Y >
  1043 	FastDelegate3(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) {
  1044 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1045 	template < class X, class Y >
  1046 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) {
  1047 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1048 	// Binding to const member functions.
  1049 	template < class X, class Y >
  1050 	FastDelegate3(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) {
  1051 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1052 	template < class X, class Y >
  1053 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) {
  1054 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1055 	// Static functions. We convert them into a member function call.
  1056 	// Note that this also provides a conversion from static functions.
  1057 	FastDelegate3(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) {
  1058 		bind(function_to_bind);	}
  1059 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) {
  1060 		m_Closure.bindstaticfunc(this, &FastDelegate3::InvokeStaticFunction, 
  1061 			function_to_bind); }
  1062 	RetType operator() (Param1 p1, Param2 p2, Param3 p3) const { // Invoke the delegate
  1063 		// this next line is the only one that violates the standard
  1064 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3); }
  1065 	inline bool operator ! () const	{	// Is it bound to anything?
  1066 			return !m_Closure; }
  1067 	inline bool empty() const	{
  1068 			return !m_Closure; }
  1069 	void clear() { m_Closure.clear();}
  1070 	// Conversion to and from the DelegateMemento storage class
  1071 	const DelegateMemento & GetMemento() { return m_Closure; }
  1072 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1073 
  1074 private:	// Invoker for static functions
  1075 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3) const {
  1076 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3); }
  1077 };
  1078 
  1079 //N=4
  1080 template<class Param1, class Param2, class Param3, class Param4, class RetType=detail::DefaultVoid>
  1081 class FastDelegate4 {
  1082 private:
  1083 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1084 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
  1085 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
  1086 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
  1087 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1088 public:
  1089 	// Typedefs to aid generic programming
  1090 	typedef FastDelegate4 type;
  1091 
  1092 	// Construction and comparison functions
  1093 	FastDelegate4() { clear(); }
  1094 	FastDelegate4(const FastDelegate4 &x) {
  1095 		m_Closure.CopyFrom(this, x.m_Closure); }
  1096 	void operator = (const FastDelegate4 &x)  {
  1097 		m_Closure.CopyFrom(this, x.m_Closure); }
  1098 	bool operator ==(const FastDelegate4 &x) const {
  1099 		return m_Closure.IsEqual(x.m_Closure);	}
  1100 	bool operator !=(const FastDelegate4 &x) const {
  1101 		return !m_Closure.IsEqual(x.m_Closure); }
  1102 	bool operator <(const FastDelegate4 &x) const {
  1103 		return m_Closure.IsLess(x.m_Closure);	}
  1104 	bool operator >(const FastDelegate4 &x) const {
  1105 		return x.m_Closure.IsLess(m_Closure);	}
  1106 	// Binding to non-const member functions
  1107 	template < class X, class Y >
  1108 	FastDelegate4(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) {
  1109 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1110 	template < class X, class Y >
  1111 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) {
  1112 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1113 	// Binding to const member functions.
  1114 	template < class X, class Y >
  1115 	FastDelegate4(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) {
  1116 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1117 	template < class X, class Y >
  1118 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) {
  1119 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1120 	// Static functions. We convert them into a member function call.
  1121 	// Note that this also provides a conversion from static functions.
  1122 	FastDelegate4(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) {
  1123 		bind(function_to_bind);	}
  1124 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) {
  1125 		m_Closure.bindstaticfunc(this, &FastDelegate4::InvokeStaticFunction, 
  1126 			function_to_bind); }
  1127 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const { // Invoke the delegate
  1128 		// this next line is the only one that violates the standard
  1129 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4); }
  1130 	inline bool operator ! () const	{	// Is it bound to anything?
  1131 			return !m_Closure; }
  1132 	inline bool empty() const	{
  1133 			return !m_Closure; }
  1134 	void clear() { m_Closure.clear();}
  1135 	// Conversion to and from the DelegateMemento storage class
  1136 	const DelegateMemento & GetMemento() { return m_Closure; }
  1137 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1138 
  1139 private:	// Invoker for static functions
  1140 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const {
  1141 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4); }
  1142 };
  1143 
  1144 //N=5
  1145 template<class Param1, class Param2, class Param3, class Param4, class Param5, class RetType=detail::DefaultVoid>
  1146 class FastDelegate5 {
  1147 private:
  1148 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1149 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
  1150 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
  1151 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
  1152 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1153 public:
  1154 	// Typedefs to aid generic programming
  1155 	typedef FastDelegate5 type;
  1156 
  1157 	// Construction and comparison functions
  1158 	FastDelegate5() { clear(); }
  1159 	FastDelegate5(const FastDelegate5 &x) {
  1160 		m_Closure.CopyFrom(this, x.m_Closure); }
  1161 	void operator = (const FastDelegate5 &x)  {
  1162 		m_Closure.CopyFrom(this, x.m_Closure); }
  1163 	bool operator ==(const FastDelegate5 &x) const {
  1164 		return m_Closure.IsEqual(x.m_Closure);	}
  1165 	bool operator !=(const FastDelegate5 &x) const {
  1166 		return !m_Closure.IsEqual(x.m_Closure); }
  1167 	bool operator <(const FastDelegate5 &x) const {
  1168 		return m_Closure.IsLess(x.m_Closure);	}
  1169 	bool operator >(const FastDelegate5 &x) const {
  1170 		return x.m_Closure.IsLess(m_Closure);	}
  1171 	// Binding to non-const member functions
  1172 	template < class X, class Y >
  1173 	FastDelegate5(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) {
  1174 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1175 	template < class X, class Y >
  1176 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) {
  1177 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1178 	// Binding to const member functions.
  1179 	template < class X, class Y >
  1180 	FastDelegate5(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) {
  1181 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1182 	template < class X, class Y >
  1183 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) {
  1184 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1185 	// Static functions. We convert them into a member function call.
  1186 	// Note that this also provides a conversion from static functions.
  1187 	FastDelegate5(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) {
  1188 		bind(function_to_bind);	}
  1189 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) {
  1190 		m_Closure.bindstaticfunc(this, &FastDelegate5::InvokeStaticFunction, 
  1191 			function_to_bind); }
  1192 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const { // Invoke the delegate
  1193 		// this next line is the only one that violates the standard
  1194 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5); }
  1195 	inline bool operator ! () const	{	// Is it bound to anything?
  1196 			return !m_Closure; }
  1197 	inline bool empty() const	{
  1198 			return !m_Closure; }
  1199 	void clear() { m_Closure.clear();}
  1200 	// Conversion to and from the DelegateMemento storage class
  1201 	const DelegateMemento & GetMemento() { return m_Closure; }
  1202 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1203 
  1204 private:	// Invoker for static functions
  1205 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const {
  1206 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5); }
  1207 };
  1208 
  1209 //N=6
  1210 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType=detail::DefaultVoid>
  1211 class FastDelegate6 {
  1212 private:
  1213 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1214 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
  1215 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
  1216 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
  1217 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1218 public:
  1219 	// Typedefs to aid generic programming
  1220 	typedef FastDelegate6 type;
  1221 
  1222 	// Construction and comparison functions
  1223 	FastDelegate6() { clear(); }
  1224 	FastDelegate6(const FastDelegate6 &x) {
  1225 		m_Closure.CopyFrom(this, x.m_Closure); }
  1226 	void operator = (const FastDelegate6 &x)  {
  1227 		m_Closure.CopyFrom(this, x.m_Closure); }
  1228 	bool operator ==(const FastDelegate6 &x) const {
  1229 		return m_Closure.IsEqual(x.m_Closure);	}
  1230 	bool operator !=(const FastDelegate6 &x) const {
  1231 		return !m_Closure.IsEqual(x.m_Closure); }
  1232 	bool operator <(const FastDelegate6 &x) const {
  1233 		return m_Closure.IsLess(x.m_Closure);	}
  1234 	bool operator >(const FastDelegate6 &x) const {
  1235 		return x.m_Closure.IsLess(m_Closure);	}
  1236 	// Binding to non-const member functions
  1237 	template < class X, class Y >
  1238 	FastDelegate6(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) {
  1239 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1240 	template < class X, class Y >
  1241 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) {
  1242 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1243 	// Binding to const member functions.
  1244 	template < class X, class Y >
  1245 	FastDelegate6(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) {
  1246 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1247 	template < class X, class Y >
  1248 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) {
  1249 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1250 	// Static functions. We convert them into a member function call.
  1251 	// Note that this also provides a conversion from static functions.
  1252 	FastDelegate6(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) {
  1253 		bind(function_to_bind);	}
  1254 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) {
  1255 		m_Closure.bindstaticfunc(this, &FastDelegate6::InvokeStaticFunction, 
  1256 			function_to_bind); }
  1257 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const { // Invoke the delegate
  1258 		// this next line is the only one that violates the standard
  1259 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6); }
  1260 	inline bool operator ! () const	{	// Is it bound to anything?
  1261 			return !m_Closure; }
  1262 	inline bool empty() const	{
  1263 			return !m_Closure; }
  1264 	void clear() { m_Closure.clear();}
  1265 	// Conversion to and from the DelegateMemento storage class
  1266 	const DelegateMemento & GetMemento() { return m_Closure; }
  1267 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1268 
  1269 private:	// Invoker for static functions
  1270 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const {
  1271 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6); }
  1272 };
  1273 
  1274 //N=7
  1275 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType=detail::DefaultVoid>
  1276 class FastDelegate7 {
  1277 private:
  1278 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1279 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
  1280 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
  1281 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
  1282 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1283 public:
  1284 	// Typedefs to aid generic programming
  1285 	typedef FastDelegate7 type;
  1286 
  1287 	// Construction and comparison functions
  1288 	FastDelegate7() { clear(); }
  1289 	FastDelegate7(const FastDelegate7 &x) {
  1290 		m_Closure.CopyFrom(this, x.m_Closure); }
  1291 	void operator = (const FastDelegate7 &x)  {
  1292 		m_Closure.CopyFrom(this, x.m_Closure); }
  1293 	bool operator ==(const FastDelegate7 &x) const {
  1294 		return m_Closure.IsEqual(x.m_Closure);	}
  1295 	bool operator !=(const FastDelegate7 &x) const {
  1296 		return !m_Closure.IsEqual(x.m_Closure); }
  1297 	bool operator <(const FastDelegate7 &x) const {
  1298 		return m_Closure.IsLess(x.m_Closure);	}
  1299 	bool operator >(const FastDelegate7 &x) const {
  1300 		return x.m_Closure.IsLess(m_Closure);	}
  1301 	// Binding to non-const member functions
  1302 	template < class X, class Y >
  1303 	FastDelegate7(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) {
  1304 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1305 	template < class X, class Y >
  1306 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) {
  1307 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1308 	// Binding to const member functions.
  1309 	template < class X, class Y >
  1310 	FastDelegate7(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) {
  1311 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1312 	template < class X, class Y >
  1313 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) {
  1314 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1315 	// Static functions. We convert them into a member function call.
  1316 	// Note that this also provides a conversion from static functions.
  1317 	FastDelegate7(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) {
  1318 		bind(function_to_bind);	}
  1319 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) {
  1320 		m_Closure.bindstaticfunc(this, &FastDelegate7::InvokeStaticFunction, 
  1321 			function_to_bind); }
  1322 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const { // Invoke the delegate
  1323 		// this next line is the only one that violates the standard
  1324 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7); }
  1325 	inline bool operator ! () const	{	// Is it bound to anything?
  1326 			return !m_Closure; }
  1327 	inline bool empty() const	{
  1328 			return !m_Closure; }
  1329 	void clear() { m_Closure.clear();}
  1330 	// Conversion to and from the DelegateMemento storage class
  1331 	const DelegateMemento & GetMemento() { return m_Closure; }
  1332 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1333 
  1334 private:	// Invoker for static functions
  1335 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const {
  1336 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7); }
  1337 };
  1338 
  1339 //N=8
  1340 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType=detail::DefaultVoid>
  1341 class FastDelegate8 {
  1342 private:
  1343 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1344 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
  1345 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
  1346 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
  1347 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1348 public:
  1349 	// Typedefs to aid generic programming
  1350 	typedef FastDelegate8 type;
  1351 
  1352 	// Construction and comparison functions
  1353 	FastDelegate8() { clear(); }
  1354 	FastDelegate8(const FastDelegate8 &x) {
  1355 		m_Closure.CopyFrom(this, x.m_Closure); }
  1356 	void operator = (const FastDelegate8 &x)  {
  1357 		m_Closure.CopyFrom(this, x.m_Closure); }
  1358 	bool operator ==(const FastDelegate8 &x) const {
  1359 		return m_Closure.IsEqual(x.m_Closure);	}
  1360 	bool operator !=(const FastDelegate8 &x) const {
  1361 		return !m_Closure.IsEqual(x.m_Closure); }
  1362 	bool operator <(const FastDelegate8 &x) const {
  1363 		return m_Closure.IsLess(x.m_Closure);	}
  1364 	bool operator >(const FastDelegate8 &x) const {
  1365 		return x.m_Closure.IsLess(m_Closure);	}
  1366 	// Binding to non-const member functions
  1367 	template < class X, class Y >
  1368 	FastDelegate8(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) {
  1369 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1370 	template < class X, class Y >
  1371 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) {
  1372 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1373 	// Binding to const member functions.
  1374 	template < class X, class Y >
  1375 	FastDelegate8(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) {
  1376 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1377 	template < class X, class Y >
  1378 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) {
  1379 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1380 	// Static functions. We convert them into a member function call.
  1381 	// Note that this also provides a conversion from static functions.
  1382 	FastDelegate8(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) {
  1383 		bind(function_to_bind);	}
  1384 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) {
  1385 		m_Closure.bindstaticfunc(this, &FastDelegate8::InvokeStaticFunction, 
  1386 			function_to_bind); }
  1387 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const { // Invoke the delegate
  1388 		// this next line is the only one that violates the standard
  1389 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8); }
  1390 	inline bool operator ! () const	{	// Is it bound to anything?
  1391 			return !m_Closure; }
  1392 	inline bool empty() const	{
  1393 			return !m_Closure; }
  1394 	void clear() { m_Closure.clear();}
  1395 	// Conversion to and from the DelegateMemento storage class
  1396 	const DelegateMemento & GetMemento() { return m_Closure; }
  1397 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1398 
  1399 private:	// Invoker for static functions
  1400 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const {
  1401 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8); }
  1402 };
  1403 
  1404 //N=9
  1405 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class RetType=detail::DefaultVoid>
  1406 class FastDelegate9 {
  1407 private:
  1408 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1409 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9);
  1410 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9);
  1411 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9);
  1412 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1413 public:
  1414 	// Typedefs to aid generic programming
  1415 	typedef FastDelegate9 type;
  1416 
  1417 	// Construction and comparison functions
  1418 	FastDelegate9() { clear(); }
  1419 	FastDelegate9(const FastDelegate9 &x) {
  1420 		m_Closure.CopyFrom(this, x.m_Closure); }
  1421 	void operator = (const FastDelegate9 &x)  {
  1422 		m_Closure.CopyFrom(this, x.m_Closure); }
  1423 	bool operator ==(const FastDelegate9 &x) const {
  1424 		return m_Closure.IsEqual(x.m_Closure);	}
  1425 	bool operator !=(const FastDelegate9 &x) const {
  1426 		return !m_Closure.IsEqual(x.m_Closure); }
  1427 	bool operator <(const FastDelegate9 &x) const {
  1428 		return m_Closure.IsLess(x.m_Closure);	}
  1429 	bool operator >(const FastDelegate9 &x) const {
  1430 		return x.m_Closure.IsLess(m_Closure);	}
  1431 	// Binding to non-const member functions
  1432 	template < class X, class Y >
  1433 	FastDelegate9(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9) ) {
  1434 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1435 	template < class X, class Y >
  1436 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9)) {
  1437 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1438 	// Binding to const member functions.
  1439 	template < class X, class Y >
  1440 	FastDelegate9(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9) const) {
  1441 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1442 	template < class X, class Y >
  1443 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9) const) {
  1444 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1445 	// Static functions. We convert them into a member function call.
  1446 	// Note that this also provides a conversion from static functions.
  1447 	FastDelegate9(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9) ) {
  1448 		bind(function_to_bind);	}
  1449 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9)) {
  1450 		m_Closure.bindstaticfunc(this, &FastDelegate9::InvokeStaticFunction, 
  1451 			function_to_bind); }
  1452 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9) const { // Invoke the delegate
  1453 		// this next line is the only one that violates the standard
  1454 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
  1455 	inline bool operator ! () const	{	// Is it bound to anything?
  1456 			return !m_Closure; }
  1457 	inline bool empty() const	{
  1458 			return !m_Closure; }
  1459 	void clear() { m_Closure.clear();}
  1460 	// Conversion to and from the DelegateMemento storage class
  1461 	const DelegateMemento & GetMemento() { return m_Closure; }
  1462 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1463 
  1464 private:	// Invoker for static functions
  1465 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9) const {
  1466 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
  1467 };
  1468 
  1469 //N=10
  1470 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class RetType=detail::DefaultVoid>
  1471 class FastDelegate10 {
  1472 private:
  1473 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1474 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10);
  1475 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10);
  1476 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10);
  1477 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1478 public:
  1479 	// Typedefs to aid generic programming
  1480 	typedef FastDelegate10 type;
  1481 
  1482 	// Construction and comparison functions
  1483 	FastDelegate10() { clear(); }
  1484 	FastDelegate10(const FastDelegate10 &x) {
  1485 		m_Closure.CopyFrom(this, x.m_Closure); }
  1486 	void operator = (const FastDelegate10 &x)  {
  1487 		m_Closure.CopyFrom(this, x.m_Closure); }
  1488 	bool operator ==(const FastDelegate10 &x) const {
  1489 		return m_Closure.IsEqual(x.m_Closure);	}
  1490 	bool operator !=(const FastDelegate10 &x) const {
  1491 		return !m_Closure.IsEqual(x.m_Closure); }
  1492 	bool operator <(const FastDelegate10 &x) const {
  1493 		return m_Closure.IsLess(x.m_Closure);	}
  1494 	bool operator >(const FastDelegate10 &x) const {
  1495 		return x.m_Closure.IsLess(m_Closure);	}
  1496 	// Binding to non-const member functions
  1497 	template < class X, class Y >
  1498 	FastDelegate10(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10) ) {
  1499 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1500 	template < class X, class Y >
  1501 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10)) {
  1502 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1503 	// Binding to const member functions.
  1504 	template < class X, class Y >
  1505 	FastDelegate10(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10) const) {
  1506 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1507 	template < class X, class Y >
  1508 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10) const) {
  1509 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1510 	// Static functions. We convert them into a member function call.
  1511 	// Note that this also provides a conversion from static functions.
  1512 	FastDelegate10(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10) ) {
  1513 		bind(function_to_bind);	}
  1514 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10)) {
  1515 		m_Closure.bindstaticfunc(this, &FastDelegate10::InvokeStaticFunction, 
  1516 			function_to_bind); }
  1517 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10) const { // Invoke the delegate
  1518 		// this next line is the only one that violates the standard
  1519 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
  1520 	inline bool operator ! () const	{	// Is it bound to anything?
  1521 			return !m_Closure; }
  1522 	inline bool empty() const	{
  1523 			return !m_Closure; }
  1524 	void clear() { m_Closure.clear();}
  1525 	// Conversion to and from the DelegateMemento storage class
  1526 	const DelegateMemento & GetMemento() { return m_Closure; }
  1527 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1528 
  1529 private:	// Invoker for static functions
  1530 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10) const {
  1531 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
  1532 };
  1533 
  1534 //N=11
  1535 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class RetType=detail::DefaultVoid>
  1536 class FastDelegate11 {
  1537 private:
  1538 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1539 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11);
  1540 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11);
  1541 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11);
  1542 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1543 public:
  1544 	// Typedefs to aid generic programming
  1545 	typedef FastDelegate11 type;
  1546 
  1547 	// Construction and comparison functions
  1548 	FastDelegate11() { clear(); }
  1549 	FastDelegate11(const FastDelegate11 &x) {
  1550 		m_Closure.CopyFrom(this, x.m_Closure); }
  1551 	void operator = (const FastDelegate11 &x)  {
  1552 		m_Closure.CopyFrom(this, x.m_Closure); }
  1553 	bool operator ==(const FastDelegate11 &x) const {
  1554 		return m_Closure.IsEqual(x.m_Closure);	}
  1555 	bool operator !=(const FastDelegate11 &x) const {
  1556 		return !m_Closure.IsEqual(x.m_Closure); }
  1557 	bool operator <(const FastDelegate11 &x) const {
  1558 		return m_Closure.IsLess(x.m_Closure);	}
  1559 	bool operator >(const FastDelegate11 &x) const {
  1560 		return x.m_Closure.IsLess(m_Closure);	}
  1561 	// Binding to non-const member functions
  1562 	template < class X, class Y >
  1563 	FastDelegate11(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11) ) {
  1564 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1565 	template < class X, class Y >
  1566 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11)) {
  1567 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1568 	// Binding to const member functions.
  1569 	template < class X, class Y >
  1570 	FastDelegate11(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11) const) {
  1571 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1572 	template < class X, class Y >
  1573 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11) const) {
  1574 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1575 	// Static functions. We convert them into a member function call.
  1576 	// Note that this also provides a conversion from static functions.
  1577 	FastDelegate11(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11) ) {
  1578 		bind(function_to_bind);	}
  1579 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11)) {
  1580 		m_Closure.bindstaticfunc(this, &FastDelegate11::InvokeStaticFunction, 
  1581 			function_to_bind); }
  1582 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11) const { // Invoke the delegate
  1583 		// this next line is the only one that violates the standard
  1584 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
  1585 	inline bool operator ! () const	{	// Is it bound to anything?
  1586 			return !m_Closure; }
  1587 	inline bool empty() const	{
  1588 			return !m_Closure; }
  1589 	void clear() { m_Closure.clear();}
  1590 	// Conversion to and from the DelegateMemento storage class
  1591 	const DelegateMemento & GetMemento() { return m_Closure; }
  1592 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1593 
  1594 private:	// Invoker for static functions
  1595 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11) const {
  1596 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
  1597 };
  1598 
  1599 //N=12
  1600 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class RetType=detail::DefaultVoid>
  1601 class FastDelegate12 {
  1602 private:
  1603 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1604 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12);
  1605 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12);
  1606 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12);
  1607 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1608 public:
  1609 	// Typedefs to aid generic programming
  1610 	typedef FastDelegate12 type;
  1611 
  1612 	// Construction and comparison functions
  1613 	FastDelegate12() { clear(); }
  1614 	FastDelegate12(const FastDelegate12 &x) {
  1615 		m_Closure.CopyFrom(this, x.m_Closure); }
  1616 	void operator = (const FastDelegate12 &x)  {
  1617 		m_Closure.CopyFrom(this, x.m_Closure); }
  1618 	bool operator ==(const FastDelegate12 &x) const {
  1619 		return m_Closure.IsEqual(x.m_Closure);	}
  1620 	bool operator !=(const FastDelegate12 &x) const {
  1621 		return !m_Closure.IsEqual(x.m_Closure); }
  1622 	bool operator <(const FastDelegate12 &x) const {
  1623 		return m_Closure.IsLess(x.m_Closure);	}
  1624 	bool operator >(const FastDelegate12 &x) const {
  1625 		return x.m_Closure.IsLess(m_Closure);	}
  1626 	// Binding to non-const member functions
  1627 	template < class X, class Y >
  1628 	FastDelegate12(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12) ) {
  1629 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1630 	template < class X, class Y >
  1631 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12)) {
  1632 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1633 	// Binding to const member functions.
  1634 	template < class X, class Y >
  1635 	FastDelegate12(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12) const) {
  1636 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1637 	template < class X, class Y >
  1638 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12) const) {
  1639 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1640 	// Static functions. We convert them into a member function call.
  1641 	// Note that this also provides a conversion from static functions.
  1642 	FastDelegate12(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12) ) {
  1643 		bind(function_to_bind);	}
  1644 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12)) {
  1645 		m_Closure.bindstaticfunc(this, &FastDelegate12::InvokeStaticFunction, 
  1646 			function_to_bind); }
  1647 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12) const { // Invoke the delegate
  1648 		// this next line is the only one that violates the standard
  1649 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
  1650 	inline bool operator ! () const	{	// Is it bound to anything?
  1651 			return !m_Closure; }
  1652 	inline bool empty() const	{
  1653 			return !m_Closure; }
  1654 	void clear() { m_Closure.clear();}
  1655 	// Conversion to and from the DelegateMemento storage class
  1656 	const DelegateMemento & GetMemento() { return m_Closure; }
  1657 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1658 
  1659 private:	// Invoker for static functions
  1660 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12) const {
  1661 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
  1662 };
  1663 
  1664 //N=13
  1665 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class RetType=detail::DefaultVoid>
  1666 class FastDelegate13 {
  1667 private:
  1668 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1669 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13);
  1670 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13);
  1671 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13);
  1672 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1673 public:
  1674 	// Typedefs to aid generic programming
  1675 	typedef FastDelegate13 type;
  1676 
  1677 	// Construction and comparison functions
  1678 	FastDelegate13() { clear(); }
  1679 	FastDelegate13(const FastDelegate13 &x) {
  1680 		m_Closure.CopyFrom(this, x.m_Closure); }
  1681 	void operator = (const FastDelegate13 &x)  {
  1682 		m_Closure.CopyFrom(this, x.m_Closure); }
  1683 	bool operator ==(const FastDelegate13 &x) const {
  1684 		return m_Closure.IsEqual(x.m_Closure);	}
  1685 	bool operator !=(const FastDelegate13 &x) const {
  1686 		return !m_Closure.IsEqual(x.m_Closure); }
  1687 	bool operator <(const FastDelegate13 &x) const {
  1688 		return m_Closure.IsLess(x.m_Closure);	}
  1689 	bool operator >(const FastDelegate13 &x) const {
  1690 		return x.m_Closure.IsLess(m_Closure);	}
  1691 	// Binding to non-const member functions
  1692 	template < class X, class Y >
  1693 	FastDelegate13(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13) ) {
  1694 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1695 	template < class X, class Y >
  1696 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13)) {
  1697 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1698 	// Binding to const member functions.
  1699 	template < class X, class Y >
  1700 	FastDelegate13(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13) const) {
  1701 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1702 	template < class X, class Y >
  1703 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13) const) {
  1704 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1705 	// Static functions. We convert them into a member function call.
  1706 	// Note that this also provides a conversion from static functions.
  1707 	FastDelegate13(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13) ) {
  1708 		bind(function_to_bind);	}
  1709 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13)) {
  1710 		m_Closure.bindstaticfunc(this, &FastDelegate13::InvokeStaticFunction, 
  1711 			function_to_bind); }
  1712 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13) const { // Invoke the delegate
  1713 		// this next line is the only one that violates the standard
  1714 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
  1715 	inline bool operator ! () const	{	// Is it bound to anything?
  1716 			return !m_Closure; }
  1717 	inline bool empty() const	{
  1718 			return !m_Closure; }
  1719 	void clear() { m_Closure.clear();}
  1720 	// Conversion to and from the DelegateMemento storage class
  1721 	const DelegateMemento & GetMemento() { return m_Closure; }
  1722 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1723 
  1724 private:	// Invoker for static functions
  1725 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13) const {
  1726 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
  1727 };
  1728 
  1729 //N=14
  1730 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class RetType=detail::DefaultVoid>
  1731 class FastDelegate14 {
  1732 private:
  1733 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1734 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14);
  1735 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14);
  1736 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14);
  1737 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1738 public:
  1739 	// Typedefs to aid generic programming
  1740 	typedef FastDelegate14 type;
  1741 
  1742 	// Construction and comparison functions
  1743 	FastDelegate14() { clear(); }
  1744 	FastDelegate14(const FastDelegate14 &x) {
  1745 		m_Closure.CopyFrom(this, x.m_Closure); }
  1746 	void operator = (const FastDelegate14 &x)  {
  1747 		m_Closure.CopyFrom(this, x.m_Closure); }
  1748 	bool operator ==(const FastDelegate14 &x) const {
  1749 		return m_Closure.IsEqual(x.m_Closure);	}
  1750 	bool operator !=(const FastDelegate14 &x) const {
  1751 		return !m_Closure.IsEqual(x.m_Closure); }
  1752 	bool operator <(const FastDelegate14 &x) const {
  1753 		return m_Closure.IsLess(x.m_Closure);	}
  1754 	bool operator >(const FastDelegate14 &x) const {
  1755 		return x.m_Closure.IsLess(m_Closure);	}
  1756 	// Binding to non-const member functions
  1757 	template < class X, class Y >
  1758 	FastDelegate14(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14) ) {
  1759 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1760 	template < class X, class Y >
  1761 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14)) {
  1762 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1763 	// Binding to const member functions.
  1764 	template < class X, class Y >
  1765 	FastDelegate14(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14) const) {
  1766 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1767 	template < class X, class Y >
  1768 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14) const) {
  1769 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1770 	// Static functions. We convert them into a member function call.
  1771 	// Note that this also provides a conversion from static functions.
  1772 	FastDelegate14(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14) ) {
  1773 		bind(function_to_bind);	}
  1774 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14)) {
  1775 		m_Closure.bindstaticfunc(this, &FastDelegate14::InvokeStaticFunction, 
  1776 			function_to_bind); }
  1777 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14) const { // Invoke the delegate
  1778 		// this next line is the only one that violates the standard
  1779 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); }
  1780 	inline bool operator ! () const	{	// Is it bound to anything?
  1781 			return !m_Closure; }
  1782 	inline bool empty() const	{
  1783 			return !m_Closure; }
  1784 	void clear() { m_Closure.clear();}
  1785 	// Conversion to and from the DelegateMemento storage class
  1786 	const DelegateMemento & GetMemento() { return m_Closure; }
  1787 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1788 
  1789 private:	// Invoker for static functions
  1790 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14) const {
  1791 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); }
  1792 };
  1793 
  1794 //N=15
  1795 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class RetType=detail::DefaultVoid>
  1796 class FastDelegate15 {
  1797 private:
  1798 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1799 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15);
  1800 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15);
  1801 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15);
  1802 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1803 public:
  1804 	// Typedefs to aid generic programming
  1805 	typedef FastDelegate15 type;
  1806 
  1807 	// Construction and comparison functions
  1808 	FastDelegate15() { clear(); }
  1809 	FastDelegate15(const FastDelegate15 &x) {
  1810 		m_Closure.CopyFrom(this, x.m_Closure); }
  1811 	void operator = (const FastDelegate15 &x)  {
  1812 		m_Closure.CopyFrom(this, x.m_Closure); }
  1813 	bool operator ==(const FastDelegate15 &x) const {
  1814 		return m_Closure.IsEqual(x.m_Closure);	}
  1815 	bool operator !=(const FastDelegate15 &x) const {
  1816 		return !m_Closure.IsEqual(x.m_Closure); }
  1817 	bool operator <(const FastDelegate15 &x) const {
  1818 		return m_Closure.IsLess(x.m_Closure);	}
  1819 	bool operator >(const FastDelegate15 &x) const {
  1820 		return x.m_Closure.IsLess(m_Closure);	}
  1821 	// Binding to non-const member functions
  1822 	template < class X, class Y >
  1823 	FastDelegate15(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15) ) {
  1824 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1825 	template < class X, class Y >
  1826 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15)) {
  1827 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1828 	// Binding to const member functions.
  1829 	template < class X, class Y >
  1830 	FastDelegate15(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15) const) {
  1831 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1832 	template < class X, class Y >
  1833 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15) const) {
  1834 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1835 	// Static functions. We convert them into a member function call.
  1836 	// Note that this also provides a conversion from static functions.
  1837 	FastDelegate15(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15) ) {
  1838 		bind(function_to_bind);	}
  1839 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15)) {
  1840 		m_Closure.bindstaticfunc(this, &FastDelegate15::InvokeStaticFunction, 
  1841 			function_to_bind); }
  1842 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15) const { // Invoke the delegate
  1843 		// this next line is the only one that violates the standard
  1844 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); }
  1845 	inline bool operator ! () const	{	// Is it bound to anything?
  1846 			return !m_Closure; }
  1847 	inline bool empty() const	{
  1848 			return !m_Closure; }
  1849 	void clear() { m_Closure.clear();}
  1850 	// Conversion to and from the DelegateMemento storage class
  1851 	const DelegateMemento & GetMemento() { return m_Closure; }
  1852 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1853 
  1854 private:	// Invoker for static functions
  1855 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15) const {
  1856 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); }
  1857 };
  1858 
  1859 //N=16
  1860 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class Param16, class RetType=detail::DefaultVoid>
  1861 class FastDelegate16 {
  1862 private:
  1863 	typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
  1864 	typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16);
  1865 	typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16);
  1866 	typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16);
  1867 	detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> m_Closure;
  1868 public:
  1869 	// Typedefs to aid generic programming
  1870 	typedef FastDelegate16 type;
  1871 
  1872 	// Construction and comparison functions
  1873 	FastDelegate16() { clear(); }
  1874 	FastDelegate16(const FastDelegate16 &x) {
  1875 		m_Closure.CopyFrom(this, x.m_Closure); }
  1876 	void operator = (const FastDelegate16 &x)  {
  1877 		m_Closure.CopyFrom(this, x.m_Closure); }
  1878 	bool operator ==(const FastDelegate16 &x) const {
  1879 		return m_Closure.IsEqual(x.m_Closure);	}
  1880 	bool operator !=(const FastDelegate16 &x) const {
  1881 		return !m_Closure.IsEqual(x.m_Closure); }
  1882 	bool operator <(const FastDelegate16 &x) const {
  1883 		return m_Closure.IsLess(x.m_Closure);	}
  1884 	bool operator >(const FastDelegate16 &x) const {
  1885 		return x.m_Closure.IsLess(m_Closure);	}
  1886 	// Binding to non-const member functions
  1887 	template < class X, class Y >
  1888 	FastDelegate16(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16) ) {
  1889 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
  1890 	template < class X, class Y >
  1891 	inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16)) {
  1892 		m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind);	}
  1893 	// Binding to const member functions.
  1894 	template < class X, class Y >
  1895 	FastDelegate16(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16) const) {
  1896 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind);	}
  1897 	template < class X, class Y >
  1898 	inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16) const) {
  1899 		m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind);	}
  1900 	// Static functions. We convert them into a member function call.
  1901 	// Note that this also provides a conversion from static functions.
  1902 	FastDelegate16(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16) ) {
  1903 		bind(function_to_bind);	}
  1904 	inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16)) {
  1905 		m_Closure.bindstaticfunc(this, &FastDelegate16::InvokeStaticFunction, 
  1906 			function_to_bind); }
  1907 	RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16) const { // Invoke the delegate
  1908 		// this next line is the only one that violates the standard
  1909 	return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16); }
  1910 	inline bool operator ! () const	{	// Is it bound to anything?
  1911 			return !m_Closure; }
  1912 	inline bool empty() const	{
  1913 			return !m_Closure; }
  1914 	void clear() { m_Closure.clear();}
  1915 	// Conversion to and from the DelegateMemento storage class
  1916 	const DelegateMemento & GetMemento() { return m_Closure; }
  1917 	void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
  1918 
  1919 private:	// Invoker for static functions
  1920 	RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16) const {
  1921 	return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16); }
  1922 };
  1923 
  1924 
  1925 ////////////////////////////////////////////////////////////////////////////////
  1926 //						Fast Delegates, part 4:
  1927 // 
  1928 //				FastDelegate<> class (Original author: Jody Hagins)
  1929 //	Allows boost::function style syntax like:
  1930 //			FastDelegate< double (int, long) >
  1931 // instead of:
  1932 //			FastDelegate2< int, long, double >
  1933 //
  1934 ////////////////////////////////////////////////////////////////////////////////
  1935 
  1936 #ifdef FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
  1937 
  1938 // Declare FastDelegate as a class template.  It will be specialized
  1939 // later for all number of arguments.
  1940 template <typename Signature>
  1941 class FastDelegate;
  1942 
  1943 //N=0
  1944 // Specialization to allow use of
  1945 // FastDelegate< R (  ) >
  1946 // instead of
  1947 // FastDelegate0 < R >
  1948 template<typename R>
  1949 class FastDelegate< R (  ) >
  1950   // Inherit from FastDelegate0 so that it can be treated just
  1951   // like a FastDelegate0
  1952   : public FastDelegate0 < R >
  1953 {
  1954 public:
  1955   // Make using the base type a bit easier via typedef.
  1956   typedef FastDelegate0 < R > BaseType;
  1957 
  1958   // Allow users access to the specific type of this delegate.
  1959   typedef FastDelegate SelfType;
  1960 
  1961   // Mimic the base class constructors.
  1962   FastDelegate() : BaseType() { }
  1963 
  1964   template < class X, class Y >
  1965   FastDelegate(Y * pthis, 
  1966     R (X::* function_to_bind)(  ))
  1967     : BaseType(pthis, function_to_bind)  { }
  1968 
  1969   template < class X, class Y >
  1970   FastDelegate(const Y *pthis,
  1971       R (X::* function_to_bind)(  ) const)
  1972     : BaseType(pthis, function_to_bind)
  1973   {  }
  1974 
  1975   FastDelegate(R (*function_to_bind)(  ))
  1976     : BaseType(function_to_bind)  { }
  1977   void operator = (const BaseType &x)  {	  
  1978 		*static_cast<BaseType*>(this) = x; }
  1979 };
  1980 
  1981 //N=1
  1982 // Specialization to allow use of
  1983 // FastDelegate< R ( Param1 ) >
  1984 // instead of
  1985 // FastDelegate1 < Param1, R >
  1986 template<typename R, class Param1>
  1987 class FastDelegate< R ( Param1 ) >
  1988   // Inherit from FastDelegate1 so that it can be treated just
  1989   // like a FastDelegate1
  1990   : public FastDelegate1 < Param1, R >
  1991 {
  1992 public:
  1993   // Make using the base type a bit easier via typedef.
  1994   typedef FastDelegate1 < Param1, R > BaseType;
  1995 
  1996   // Allow users access to the specific type of this delegate.
  1997   typedef FastDelegate SelfType;
  1998 
  1999   // Mimic the base class constructors.
  2000   FastDelegate() : BaseType() { }
  2001 
  2002   template < class X, class Y >
  2003   FastDelegate(Y * pthis, 
  2004     R (X::* function_to_bind)( Param1 p1 ))
  2005     : BaseType(pthis, function_to_bind)  { }
  2006 
  2007   template < class X, class Y >
  2008   FastDelegate(const Y *pthis,
  2009       R (X::* function_to_bind)( Param1 p1 ) const)
  2010     : BaseType(pthis, function_to_bind)
  2011   {  }
  2012 
  2013   FastDelegate(R (*function_to_bind)( Param1 p1 ))
  2014     : BaseType(function_to_bind)  { }
  2015   void operator = (const BaseType &x)  {	  
  2016 		*static_cast<BaseType*>(this) = x; }
  2017 };
  2018 
  2019 //N=2
  2020 // Specialization to allow use of
  2021 // FastDelegate< R ( Param1, Param2 ) >
  2022 // instead of
  2023 // FastDelegate2 < Param1, Param2, R >
  2024 template<typename R, class Param1, class Param2>
  2025 class FastDelegate< R ( Param1, Param2 ) >
  2026   // Inherit from FastDelegate2 so that it can be treated just
  2027   // like a FastDelegate2
  2028   : public FastDelegate2 < Param1, Param2, R >
  2029 {
  2030 public:
  2031   // Make using the base type a bit easier via typedef.
  2032   typedef FastDelegate2 < Param1, Param2, R > BaseType;
  2033 
  2034   // Allow users access to the specific type of this delegate.
  2035   typedef FastDelegate SelfType;
  2036 
  2037   // Mimic the base class constructors.
  2038   FastDelegate() : BaseType() { }
  2039 
  2040   template < class X, class Y >
  2041   FastDelegate(Y * pthis, 
  2042     R (X::* function_to_bind)( Param1 p1, Param2 p2 ))
  2043     : BaseType(pthis, function_to_bind)  { }
  2044 
  2045   template < class X, class Y >
  2046   FastDelegate(const Y *pthis,
  2047       R (X::* function_to_bind)( Param1 p1, Param2 p2 ) const)
  2048     : BaseType(pthis, function_to_bind)
  2049   {  }
  2050 
  2051   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2 ))
  2052     : BaseType(function_to_bind)  { }
  2053   void operator = (const BaseType &x)  {	  
  2054 		*static_cast<BaseType*>(this) = x; }
  2055 };
  2056 
  2057 //N=3
  2058 // Specialization to allow use of
  2059 // FastDelegate< R ( Param1, Param2, Param3 ) >
  2060 // instead of
  2061 // FastDelegate3 < Param1, Param2, Param3, R >
  2062 template<typename R, class Param1, class Param2, class Param3>
  2063 class FastDelegate< R ( Param1, Param2, Param3 ) >
  2064   // Inherit from FastDelegate3 so that it can be treated just
  2065   // like a FastDelegate3
  2066   : public FastDelegate3 < Param1, Param2, Param3, R >
  2067 {
  2068 public:
  2069   // Make using the base type a bit easier via typedef.
  2070   typedef FastDelegate3 < Param1, Param2, Param3, R > BaseType;
  2071 
  2072   // Allow users access to the specific type of this delegate.
  2073   typedef FastDelegate SelfType;
  2074 
  2075   // Mimic the base class constructors.
  2076   FastDelegate() : BaseType() { }
  2077 
  2078   template < class X, class Y >
  2079   FastDelegate(Y * pthis, 
  2080     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ))
  2081     : BaseType(pthis, function_to_bind)  { }
  2082 
  2083   template < class X, class Y >
  2084   FastDelegate(const Y *pthis,
  2085       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ) const)
  2086     : BaseType(pthis, function_to_bind)
  2087   {  }
  2088 
  2089   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ))
  2090     : BaseType(function_to_bind)  { }
  2091   void operator = (const BaseType &x)  {	  
  2092 		*static_cast<BaseType*>(this) = x; }
  2093 };
  2094 
  2095 //N=4
  2096 // Specialization to allow use of
  2097 // FastDelegate< R ( Param1, Param2, Param3, Param4 ) >
  2098 // instead of
  2099 // FastDelegate4 < Param1, Param2, Param3, Param4, R >
  2100 template<typename R, class Param1, class Param2, class Param3, class Param4>
  2101 class FastDelegate< R ( Param1, Param2, Param3, Param4 ) >
  2102   // Inherit from FastDelegate4 so that it can be treated just
  2103   // like a FastDelegate4
  2104   : public FastDelegate4 < Param1, Param2, Param3, Param4, R >
  2105 {
  2106 public:
  2107   // Make using the base type a bit easier via typedef.
  2108   typedef FastDelegate4 < Param1, Param2, Param3, Param4, R > BaseType;
  2109 
  2110   // Allow users access to the specific type of this delegate.
  2111   typedef FastDelegate SelfType;
  2112 
  2113   // Mimic the base class constructors.
  2114   FastDelegate() : BaseType() { }
  2115 
  2116   template < class X, class Y >
  2117   FastDelegate(Y * pthis, 
  2118     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ))
  2119     : BaseType(pthis, function_to_bind)  { }
  2120 
  2121   template < class X, class Y >
  2122   FastDelegate(const Y *pthis,
  2123       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ) const)
  2124     : BaseType(pthis, function_to_bind)
  2125   {  }
  2126 
  2127   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ))
  2128     : BaseType(function_to_bind)  { }
  2129   void operator = (const BaseType &x)  {	  
  2130 		*static_cast<BaseType*>(this) = x; }
  2131 };
  2132 
  2133 //N=5
  2134 // Specialization to allow use of
  2135 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5 ) >
  2136 // instead of
  2137 // FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R >
  2138 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5>
  2139 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5 ) >
  2140   // Inherit from FastDelegate5 so that it can be treated just
  2141   // like a FastDelegate5
  2142   : public FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R >
  2143 {
  2144 public:
  2145   // Make using the base type a bit easier via typedef.
  2146   typedef FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R > BaseType;
  2147 
  2148   // Allow users access to the specific type of this delegate.
  2149   typedef FastDelegate SelfType;
  2150 
  2151   // Mimic the base class constructors.
  2152   FastDelegate() : BaseType() { }
  2153 
  2154   template < class X, class Y >
  2155   FastDelegate(Y * pthis, 
  2156     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ))
  2157     : BaseType(pthis, function_to_bind)  { }
  2158 
  2159   template < class X, class Y >
  2160   FastDelegate(const Y *pthis,
  2161       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ) const)
  2162     : BaseType(pthis, function_to_bind)
  2163   {  }
  2164 
  2165   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ))
  2166     : BaseType(function_to_bind)  { }
  2167   void operator = (const BaseType &x)  {	  
  2168 		*static_cast<BaseType*>(this) = x; }
  2169 };
  2170 
  2171 //N=6
  2172 // Specialization to allow use of
  2173 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6 ) >
  2174 // instead of
  2175 // FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R >
  2176 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6>
  2177 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6 ) >
  2178   // Inherit from FastDelegate6 so that it can be treated just
  2179   // like a FastDelegate6
  2180   : public FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R >
  2181 {
  2182 public:
  2183   // Make using the base type a bit easier via typedef.
  2184   typedef FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R > BaseType;
  2185 
  2186   // Allow users access to the specific type of this delegate.
  2187   typedef FastDelegate SelfType;
  2188 
  2189   // Mimic the base class constructors.
  2190   FastDelegate() : BaseType() { }
  2191 
  2192   template < class X, class Y >
  2193   FastDelegate(Y * pthis, 
  2194     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ))
  2195     : BaseType(pthis, function_to_bind)  { }
  2196 
  2197   template < class X, class Y >
  2198   FastDelegate(const Y *pthis,
  2199       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ) const)
  2200     : BaseType(pthis, function_to_bind)
  2201   {  }
  2202 
  2203   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ))
  2204     : BaseType(function_to_bind)  { }
  2205   void operator = (const BaseType &x)  {	  
  2206 		*static_cast<BaseType*>(this) = x; }
  2207 };
  2208 
  2209 //N=7
  2210 // Specialization to allow use of
  2211 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7 ) >
  2212 // instead of
  2213 // FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R >
  2214 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7>
  2215 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7 ) >
  2216   // Inherit from FastDelegate7 so that it can be treated just
  2217   // like a FastDelegate7
  2218   : public FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R >
  2219 {
  2220 public:
  2221   // Make using the base type a bit easier via typedef.
  2222   typedef FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R > BaseType;
  2223 
  2224   // Allow users access to the specific type of this delegate.
  2225   typedef FastDelegate SelfType;
  2226 
  2227   // Mimic the base class constructors.
  2228   FastDelegate() : BaseType() { }
  2229 
  2230   template < class X, class Y >
  2231   FastDelegate(Y * pthis, 
  2232     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ))
  2233     : BaseType(pthis, function_to_bind)  { }
  2234 
  2235   template < class X, class Y >
  2236   FastDelegate(const Y *pthis,
  2237       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ) const)
  2238     : BaseType(pthis, function_to_bind)
  2239   {  }
  2240 
  2241   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ))
  2242     : BaseType(function_to_bind)  { }
  2243   void operator = (const BaseType &x)  {	  
  2244 		*static_cast<BaseType*>(this) = x; }
  2245 };
  2246 
  2247 //N=8
  2248 // Specialization to allow use of
  2249 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8 ) >
  2250 // instead of
  2251 // FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R >
  2252 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8>
  2253 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8 ) >
  2254   // Inherit from FastDelegate8 so that it can be treated just
  2255   // like a FastDelegate8
  2256   : public FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R >
  2257 {
  2258 public:
  2259   // Make using the base type a bit easier via typedef.
  2260   typedef FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R > BaseType;
  2261 
  2262   // Allow users access to the specific type of this delegate.
  2263   typedef FastDelegate SelfType;
  2264 
  2265   // Mimic the base class constructors.
  2266   FastDelegate() : BaseType() { }
  2267 
  2268   template < class X, class Y >
  2269   FastDelegate(Y * pthis, 
  2270     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ))
  2271     : BaseType(pthis, function_to_bind)  { }
  2272 
  2273   template < class X, class Y >
  2274   FastDelegate(const Y *pthis,
  2275       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ) const)
  2276     : BaseType(pthis, function_to_bind)
  2277   {  }
  2278 
  2279   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ))
  2280     : BaseType(function_to_bind)  { }
  2281   void operator = (const BaseType &x)  {	  
  2282 		*static_cast<BaseType*>(this) = x; }
  2283 };
  2284 
  2285 //N=9
  2286 // Specialization to allow use of
  2287 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9 ) >
  2288 // instead of
  2289 // FastDelegate9 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, R >
  2290 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9>
  2291 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9 ) >
  2292   // Inherit from FastDelegate9 so that it can be treated just
  2293   // like a FastDelegate9
  2294   : public FastDelegate9 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, R >
  2295 {
  2296 public:
  2297   // Make using the base type a bit easier via typedef.
  2298   typedef FastDelegate9 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, R > BaseType;
  2299 
  2300   // Allow users access to the specific type of this delegate.
  2301   typedef FastDelegate SelfType;
  2302 
  2303   // Mimic the base class constructors.
  2304   FastDelegate() : BaseType() { }
  2305 
  2306   template < class X, class Y >
  2307   FastDelegate(Y * pthis, 
  2308     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9 ))
  2309     : BaseType(pthis, function_to_bind)  { }
  2310 
  2311   template < class X, class Y >
  2312   FastDelegate(const Y *pthis,
  2313       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9 ) const)
  2314     : BaseType(pthis, function_to_bind)
  2315   {  }
  2316 
  2317   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9 ))
  2318     : BaseType(function_to_bind)  { }
  2319   void operator = (const BaseType &x)  {	  
  2320 		*static_cast<BaseType*>(this) = x; }
  2321 };
  2322 
  2323 //N=10
  2324 // Specialization to allow use of
  2325 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10 ) >
  2326 // instead of
  2327 // FastDelegate10 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, R >
  2328 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10>
  2329 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10 ) >
  2330   // Inherit from FastDelegate10 so that it can be treated just
  2331   // like a FastDelegate10
  2332   : public FastDelegate10 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, R >
  2333 {
  2334 public:
  2335   // Make using the base type a bit easier via typedef.
  2336   typedef FastDelegate10 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, R > BaseType;
  2337 
  2338   // Allow users access to the specific type of this delegate.
  2339   typedef FastDelegate SelfType;
  2340 
  2341   // Mimic the base class constructors.
  2342   FastDelegate() : BaseType() { }
  2343 
  2344   template < class X, class Y >
  2345   FastDelegate(Y * pthis, 
  2346     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10 ))
  2347     : BaseType(pthis, function_to_bind)  { }
  2348 
  2349   template < class X, class Y >
  2350   FastDelegate(const Y *pthis,
  2351       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10 ) const)
  2352     : BaseType(pthis, function_to_bind)
  2353   {  }
  2354 
  2355   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10 ))
  2356     : BaseType(function_to_bind)  { }
  2357   void operator = (const BaseType &x)  {	  
  2358 		*static_cast<BaseType*>(this) = x; }
  2359 };
  2360 
  2361 //N=11
  2362 // Specialization to allow use of
  2363 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11 ) >
  2364 // instead of
  2365 // FastDelegate11 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, R >
  2366 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11>
  2367 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11 ) >
  2368   // Inherit from FastDelegate11 so that it can be treated just
  2369   // like a FastDelegate11
  2370   : public FastDelegate11 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, R >
  2371 {
  2372 public:
  2373   // Make using the base type a bit easier via typedef.
  2374   typedef FastDelegate11 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, R > BaseType;
  2375 
  2376   // Allow users access to the specific type of this delegate.
  2377   typedef FastDelegate SelfType;
  2378 
  2379   // Mimic the base class constructors.
  2380   FastDelegate() : BaseType() { }
  2381 
  2382   template < class X, class Y >
  2383   FastDelegate(Y * pthis, 
  2384     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11 ))
  2385     : BaseType(pthis, function_to_bind)  { }
  2386 
  2387   template < class X, class Y >
  2388   FastDelegate(const Y *pthis,
  2389       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11 ) const)
  2390     : BaseType(pthis, function_to_bind)
  2391   {  }
  2392 
  2393   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11 ))
  2394     : BaseType(function_to_bind)  { }
  2395   void operator = (const BaseType &x)  {	  
  2396 		*static_cast<BaseType*>(this) = x; }
  2397 };
  2398 
  2399 //N=12
  2400 // Specialization to allow use of
  2401 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12 ) >
  2402 // instead of
  2403 // FastDelegate12 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, R >
  2404 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12>
  2405 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12 ) >
  2406   // Inherit from FastDelegate12 so that it can be treated just
  2407   // like a FastDelegate12
  2408   : public FastDelegate12 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, R >
  2409 {
  2410 public:
  2411   // Make using the base type a bit easier via typedef.
  2412   typedef FastDelegate12 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, R > BaseType;
  2413 
  2414   // Allow users access to the specific type of this delegate.
  2415   typedef FastDelegate SelfType;
  2416 
  2417   // Mimic the base class constructors.
  2418   FastDelegate() : BaseType() { }
  2419 
  2420   template < class X, class Y >
  2421   FastDelegate(Y * pthis, 
  2422     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12 ))
  2423     : BaseType(pthis, function_to_bind)  { }
  2424 
  2425   template < class X, class Y >
  2426   FastDelegate(const Y *pthis,
  2427       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12 ) const)
  2428     : BaseType(pthis, function_to_bind)
  2429   {  }
  2430 
  2431   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12 ))
  2432     : BaseType(function_to_bind)  { }
  2433   void operator = (const BaseType &x)  {	  
  2434 		*static_cast<BaseType*>(this) = x; }
  2435 };
  2436 
  2437 //N=13
  2438 // Specialization to allow use of
  2439 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13 ) >
  2440 // instead of
  2441 // FastDelegate13 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, R >
  2442 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13>
  2443 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13 ) >
  2444   // Inherit from FastDelegate13 so that it can be treated just
  2445   // like a FastDelegate13
  2446   : public FastDelegate13 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, R >
  2447 {
  2448 public:
  2449   // Make using the base type a bit easier via typedef.
  2450   typedef FastDelegate13 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, R > BaseType;
  2451 
  2452   // Allow users access to the specific type of this delegate.
  2453   typedef FastDelegate SelfType;
  2454 
  2455   // Mimic the base class constructors.
  2456   FastDelegate() : BaseType() { }
  2457 
  2458   template < class X, class Y >
  2459   FastDelegate(Y * pthis, 
  2460     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13 ))
  2461     : BaseType(pthis, function_to_bind)  { }
  2462 
  2463   template < class X, class Y >
  2464   FastDelegate(const Y *pthis,
  2465       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13 ) const)
  2466     : BaseType(pthis, function_to_bind)
  2467   {  }
  2468 
  2469   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13 ))
  2470     : BaseType(function_to_bind)  { }
  2471   void operator = (const BaseType &x)  {	  
  2472 		*static_cast<BaseType*>(this) = x; }
  2473 };
  2474 
  2475 //N=14
  2476 // Specialization to allow use of
  2477 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14 ) >
  2478 // instead of
  2479 // FastDelegate14 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, R >
  2480 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14>
  2481 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14 ) >
  2482   // Inherit from FastDelegate14 so that it can be treated just
  2483   // like a FastDelegate14
  2484   : public FastDelegate14 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, R >
  2485 {
  2486 public:
  2487   // Make using the base type a bit easier via typedef.
  2488   typedef FastDelegate14 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, R > BaseType;
  2489 
  2490   // Allow users access to the specific type of this delegate.
  2491   typedef FastDelegate SelfType;
  2492 
  2493   // Mimic the base class constructors.
  2494   FastDelegate() : BaseType() { }
  2495 
  2496   template < class X, class Y >
  2497   FastDelegate(Y * pthis, 
  2498     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14 ))
  2499     : BaseType(pthis, function_to_bind)  { }
  2500 
  2501   template < class X, class Y >
  2502   FastDelegate(const Y *pthis,
  2503       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14 ) const)
  2504     : BaseType(pthis, function_to_bind)
  2505   {  }
  2506 
  2507   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14 ))
  2508     : BaseType(function_to_bind)  { }
  2509   void operator = (const BaseType &x)  {	  
  2510 		*static_cast<BaseType*>(this) = x; }
  2511 };
  2512 
  2513 //N=15
  2514 // Specialization to allow use of
  2515 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15 ) >
  2516 // instead of
  2517 // FastDelegate15 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, R >
  2518 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15>
  2519 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15 ) >
  2520   // Inherit from FastDelegate15 so that it can be treated just
  2521   // like a FastDelegate15
  2522   : public FastDelegate15 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, R >
  2523 {
  2524 public:
  2525   // Make using the base type a bit easier via typedef.
  2526   typedef FastDelegate15 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, R > BaseType;
  2527 
  2528   // Allow users access to the specific type of this delegate.
  2529   typedef FastDelegate SelfType;
  2530 
  2531   // Mimic the base class constructors.
  2532   FastDelegate() : BaseType() { }
  2533 
  2534   template < class X, class Y >
  2535   FastDelegate(Y * pthis, 
  2536     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15 ))
  2537     : BaseType(pthis, function_to_bind)  { }
  2538 
  2539   template < class X, class Y >
  2540   FastDelegate(const Y *pthis,
  2541       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15 ) const)
  2542     : BaseType(pthis, function_to_bind)
  2543   {  }
  2544 
  2545   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15 ))
  2546     : BaseType(function_to_bind)  { }
  2547   void operator = (const BaseType &x)  {	  
  2548 		*static_cast<BaseType*>(this) = x; }
  2549 };
  2550 
  2551 //N=16
  2552 // Specialization to allow use of
  2553 // FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16 ) >
  2554 // instead of
  2555 // FastDelegate16 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, R >
  2556 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class Param16>
  2557 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16 ) >
  2558   // Inherit from FastDelegate16 so that it can be treated just
  2559   // like a FastDelegate16
  2560   : public FastDelegate16 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, R >
  2561 {
  2562 public:
  2563   // Make using the base type a bit easier via typedef.
  2564   typedef FastDelegate16 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, R > BaseType;
  2565 
  2566   // Allow users access to the specific type of this delegate.
  2567   typedef FastDelegate SelfType;
  2568 
  2569   // Mimic the base class constructors.
  2570   FastDelegate() : BaseType() { }
  2571 
  2572   template < class X, class Y >
  2573   FastDelegate(Y * pthis, 
  2574     R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16 ))
  2575     : BaseType(pthis, function_to_bind)  { }
  2576 
  2577   template < class X, class Y >
  2578   FastDelegate(const Y *pthis,
  2579       R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16 ) const)
  2580     : BaseType(pthis, function_to_bind)
  2581   {  }
  2582 
  2583   FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16 ))
  2584     : BaseType(function_to_bind)  { }
  2585   void operator = (const BaseType &x)  {	  
  2586 		*static_cast<BaseType*>(this) = x; }
  2587 };
  2588 
  2589 
  2590 #endif //FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
  2591 
  2592 ////////////////////////////////////////////////////////////////////////////////
  2593 //						Fast Delegates, part 5:
  2594 //
  2595 //				MakeDelegate() helper function
  2596 //
  2597 //			MakeDelegate(&x, &X::func) returns a fastdelegate of the type
  2598 //			necessary for calling x.func() with the correct number of arguments.
  2599 //			This makes it possible to eliminate many typedefs from user code.
  2600 //
  2601 ////////////////////////////////////////////////////////////////////////////////
  2602 
  2603 // Also declare overloads of a MakeDelegate() global function to 
  2604 // reduce the need for typedefs.
  2605 // We need seperate overloads for const and non-const member functions.
  2606 // Also, because of the weird rule about the class of derived member function pointers,
  2607 // implicit downcasts may need to be applied later to the 'this' pointer.
  2608 // That's why two classes (X and Y) appear in the definitions. Y must be implicitly
  2609 // castable to X.
  2610 
  2611 // Workaround for VC6. VC6 needs void return types converted into DefaultVoid.
  2612 // GCC 3.2 and later won't compile this unless it's preceded by 'typename',
  2613 // but VC6 doesn't allow 'typename' in this context.
  2614 // So, I have to use a macro.
  2615 
  2616 #ifdef FASTDLGT_VC6
  2617 #define FASTDLGT_RETTYPE detail::VoidToDefaultVoid<RetType>::type
  2618 #else 
  2619 #define FASTDLGT_RETTYPE RetType
  2620 #endif
  2621 
  2622 //N=0
  2623 template <class X, class Y, class RetType>
  2624 FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)()) { 
  2625 	return FastDelegate0<FASTDLGT_RETTYPE>(x, func);
  2626 }
  2627 
  2628 template <class X, class Y, class RetType>
  2629 FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)() const) { 
  2630 	return FastDelegate0<FASTDLGT_RETTYPE>(x, func);
  2631 }
  2632 
  2633 template <class RetType>
  2634 FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)()) { 
  2635 	return FastDelegate0<FASTDLGT_RETTYPE>(func);
  2636 }
  2637 
  2638 //N=1
  2639 template <class X, class Y, class Param1, class RetType>
  2640 FastDelegate1<Param1, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1)) { 
  2641 	return FastDelegate1<Param1, FASTDLGT_RETTYPE>(x, func);
  2642 }
  2643 
  2644 template <class X, class Y, class Param1, class RetType>
  2645 FastDelegate1<Param1, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1) const) { 
  2646 	return FastDelegate1<Param1, FASTDLGT_RETTYPE>(x, func);
  2647 }
  2648 
  2649 template <class Param1, class RetType>
  2650 FastDelegate1<Param1, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1)) { 
  2651 	return FastDelegate1<Param1, FASTDLGT_RETTYPE>(func);
  2652 }
  2653 
  2654 //N=2
  2655 template <class X, class Y, class Param1, class Param2, class RetType>
  2656 FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2)) { 
  2657 	return FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE>(x, func);
  2658 }
  2659 
  2660 template <class X, class Y, class Param1, class Param2, class RetType>
  2661 FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2) const) { 
  2662 	return FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE>(x, func);
  2663 }
  2664 
  2665 template <class Param1, class Param2, class RetType>
  2666 FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2)) { 
  2667 	return FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE>(func);
  2668 }
  2669 
  2670 //N=3
  2671 template <class X, class Y, class Param1, class Param2, class Param3, class RetType>
  2672 FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3)) { 
  2673 	return FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE>(x, func);
  2674 }
  2675 
  2676 template <class X, class Y, class Param1, class Param2, class Param3, class RetType>
  2677 FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3) const) { 
  2678 	return FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE>(x, func);
  2679 }
  2680 
  2681 template <class Param1, class Param2, class Param3, class RetType>
  2682 FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3)) { 
  2683 	return FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE>(func);
  2684 }
  2685 
  2686 //N=4
  2687 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class RetType>
  2688 FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) { 
  2689 	return FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE>(x, func);
  2690 }
  2691 
  2692 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class RetType>
  2693 FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) { 
  2694 	return FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE>(x, func);
  2695 }
  2696 
  2697 template <class Param1, class Param2, class Param3, class Param4, class RetType>
  2698 FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) { 
  2699 	return FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE>(func);
  2700 }
  2701 
  2702 //N=5
  2703 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
  2704 FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) { 
  2705 	return FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE>(x, func);
  2706 }
  2707 
  2708 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
  2709 FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) { 
  2710 	return FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE>(x, func);
  2711 }
  2712 
  2713 template <class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
  2714 FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) { 
  2715 	return FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE>(func);
  2716 }
  2717 
  2718 //N=6
  2719 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
  2720 FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) { 
  2721 	return FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE>(x, func);
  2722 }
  2723 
  2724 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
  2725 FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) { 
  2726 	return FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE>(x, func);
  2727 }
  2728 
  2729 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
  2730 FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) { 
  2731 	return FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE>(func);
  2732 }
  2733 
  2734 //N=7
  2735 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
  2736 FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) { 
  2737 	return FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE>(x, func);
  2738 }
  2739 
  2740 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
  2741 FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) { 
  2742 	return FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE>(x, func);
  2743 }
  2744 
  2745 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
  2746 FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) { 
  2747 	return FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE>(func);
  2748 }
  2749 
  2750 //N=8
  2751 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
  2752 FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) { 
  2753 	return FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE>(x, func);
  2754 }
  2755 
  2756 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
  2757 FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) { 
  2758 	return FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE>(x, func);
  2759 }
  2760 
  2761 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
  2762 FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) { 
  2763 	return FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE>(func);
  2764 }
  2765 
  2766 //N=9
  2767 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class RetType>
  2768 FastDelegate9<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9)) { 
  2769 	return FastDelegate9<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, FASTDLGT_RETTYPE>(x, func);
  2770 }
  2771 
  2772 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class RetType>
  2773 FastDelegate9<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9) const) { 
  2774 	return FastDelegate9<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, FASTDLGT_RETTYPE>(x, func);
  2775 }
  2776 
  2777 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class RetType>
  2778 FastDelegate9<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9)) { 
  2779 	return FastDelegate9<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, FASTDLGT_RETTYPE>(func);
  2780 }
  2781 
  2782 //N=10
  2783 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class RetType>
  2784 FastDelegate10<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10)) { 
  2785 	return FastDelegate10<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, FASTDLGT_RETTYPE>(x, func);
  2786 }
  2787 
  2788 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class RetType>
  2789 FastDelegate10<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10) const) { 
  2790 	return FastDelegate10<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, FASTDLGT_RETTYPE>(x, func);
  2791 }
  2792 
  2793 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class RetType>
  2794 FastDelegate10<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10)) { 
  2795 	return FastDelegate10<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, FASTDLGT_RETTYPE>(func);
  2796 }
  2797 
  2798 //N=11
  2799 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class RetType>
  2800 FastDelegate11<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11)) { 
  2801 	return FastDelegate11<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, FASTDLGT_RETTYPE>(x, func);
  2802 }
  2803 
  2804 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class RetType>
  2805 FastDelegate11<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11) const) { 
  2806 	return FastDelegate11<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, FASTDLGT_RETTYPE>(x, func);
  2807 }
  2808 
  2809 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class RetType>
  2810 FastDelegate11<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11)) { 
  2811 	return FastDelegate11<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, FASTDLGT_RETTYPE>(func);
  2812 }
  2813 
  2814 //N=12
  2815 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class RetType>
  2816 FastDelegate12<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12)) { 
  2817 	return FastDelegate12<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, FASTDLGT_RETTYPE>(x, func);
  2818 }
  2819 
  2820 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class RetType>
  2821 FastDelegate12<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12) const) { 
  2822 	return FastDelegate12<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, FASTDLGT_RETTYPE>(x, func);
  2823 }
  2824 
  2825 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class RetType>
  2826 FastDelegate12<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12)) { 
  2827 	return FastDelegate12<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, FASTDLGT_RETTYPE>(func);
  2828 }
  2829 
  2830 //N=13
  2831 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class RetType>
  2832 FastDelegate13<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13)) { 
  2833 	return FastDelegate13<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, FASTDLGT_RETTYPE>(x, func);
  2834 }
  2835 
  2836 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class RetType>
  2837 FastDelegate13<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13) const) { 
  2838 	return FastDelegate13<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, FASTDLGT_RETTYPE>(x, func);
  2839 }
  2840 
  2841 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class RetType>
  2842 FastDelegate13<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13)) { 
  2843 	return FastDelegate13<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, FASTDLGT_RETTYPE>(func);
  2844 }
  2845 
  2846 //N=14
  2847 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class RetType>
  2848 FastDelegate14<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14)) { 
  2849 	return FastDelegate14<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, FASTDLGT_RETTYPE>(x, func);
  2850 }
  2851 
  2852 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class RetType>
  2853 FastDelegate14<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14) const) { 
  2854 	return FastDelegate14<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, FASTDLGT_RETTYPE>(x, func);
  2855 }
  2856 
  2857 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class RetType>
  2858 FastDelegate14<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14)) { 
  2859 	return FastDelegate14<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, FASTDLGT_RETTYPE>(func);
  2860 }
  2861 
  2862 //N=15
  2863 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class RetType>
  2864 FastDelegate15<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15)) { 
  2865 	return FastDelegate15<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, FASTDLGT_RETTYPE>(x, func);
  2866 }
  2867 
  2868 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class RetType>
  2869 FastDelegate15<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15) const) { 
  2870 	return FastDelegate15<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, FASTDLGT_RETTYPE>(x, func);
  2871 }
  2872 
  2873 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class RetType>
  2874 FastDelegate15<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15)) { 
  2875 	return FastDelegate15<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, FASTDLGT_RETTYPE>(func);
  2876 }
  2877 
  2878 //N=16
  2879 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class Param16, class RetType>
  2880 FastDelegate16<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16)) { 
  2881 	return FastDelegate16<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, FASTDLGT_RETTYPE>(x, func);
  2882 }
  2883 
  2884 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class Param16, class RetType>
  2885 FastDelegate16<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16) const) { 
  2886 	return FastDelegate16<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, FASTDLGT_RETTYPE>(x, func);
  2887 }
  2888 
  2889 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Param9, class Param10, class Param11, class Param12, class Param13, class Param14, class Param15, class Param16, class RetType>
  2890 FastDelegate16<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, FASTDLGT_RETTYPE> MakeDelegate(RetType (*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8, Param9 p9, Param10 p10, Param11 p11, Param12 p12, Param13 p13, Param14 p14, Param15 p15, Param16 p16)) { 
  2891 	return FastDelegate16<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15, Param16, FASTDLGT_RETTYPE>(func);
  2892 }
  2893 
  2894 
  2895  // clean up after ourselves...
  2896 #undef FASTDLGT_RETTYPE
  2897 
  2898 } // namespace fastdelegate
  2899 
  2900 #endif // !defined(FASTDELEGATE_H)
  2901