![]() |
![]() |
#include <Iguana/Utilities/classlib/utils/MultiMethod.h>
Public Types | |
typedef MultiMethodCarrier < M::NVIRT, M::NNONVIRT, M, typename M::RTYPE, P > | Carrier |
Public Member Functions | |
MultiMethodMember (void) | |
~MultiMethodMember (void) |
We use ugly black magic to deduce what the arguments for the multi-method really were and how they should be converted to the real arguments this family member takes. We use overloading of template functions (= overloading and template unification) to select a stub that matches the arguments from the function the user supplied (F, prototyped as P), and the definitions in M, the multi-method type.
Unfortunately we cannot carry the address of the user function F through this mechanism -- not all compilers (at least gcc 2.95.2) do not seem to be able to deduce the template arguments for the `MultiMethodStub' call if F is present. So we initialise a class static pointer in the stub class so that when the stub function is called, it can jump to F. This of course assumes the template arguments create a unique class, which should be the case -- and if it isn't, the call will die from `ambiguity' first anyway.
We do all initialisation in the stub class. Some compilers don't like to take to address of the "stub" function in the expression, but of course let us take the address within the stub itself.
(Note: It might actually be possible to carry F through by having a yet another set of stub classes -- but then we would have to use to levels of function calls and rely on compiler optimising one of them away (when the stub is called after dispatch). It is not obvious that that would be any better than the present hack.)
An instance of this class is created for every family member defined with MMM_DEFUN_FUNC or MMM_DEFUN_METHOD.
Definition at line 696 of file MultiMethod.h.
typedef MultiMethodCarrier<M::NVIRT, M::NNONVIRT, M, typename M::RTYPE, P> lat::MultiMethodMember< M, P, F, D >::Carrier |
Definition at line 697 of file MultiMethod.h.
lat::MultiMethodMember< M, P, F, D >::MultiMethodMember | ( | void | ) | [inline] |
Definition at line 698 of file MultiMethod.h.
References funct::D, and lat::MultiMethodStub().
00698 { MultiMethodStub ((Carrier *)0)->init(D,F); }
lat::MultiMethodMember< M, P, F, D >::~MultiMethodMember | ( | void | ) | [inline] |
Definition at line 699 of file MultiMethod.h.
References funct::D, and lat::MultiMethodStub().
00699 { MultiMethodStub ((Carrier *)0)->reset(D); }