From 31b1b37ee9ad2706302fa68b67a418d71abcbc0b Mon Sep 17 00:00:00 2001 From: humesikkins Date: Fri, 21 Mar 2003 16:54:35 +0000 Subject: [PATCH] new explicit template argument specification workaround for FnDispatcher::Add git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@126 7ec92016-0320-0410-acc4-a06ded1c099a --- MSVC/1200/MultiMethods.h | 72 +++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 12 deletions(-) diff --git a/MSVC/1200/MultiMethods.h b/MSVC/1200/MultiMethods.h index fea09ce..fc27fb8 100644 --- a/MSVC/1200/MultiMethods.h +++ b/MSVC/1200/MultiMethods.h @@ -13,23 +13,24 @@ // without express or implied warranty. //////////////////////////////////////////////////////////////////////////////// -// Last update: Mar 20, 2003 -// Interface change for FnDispatcher::Add: -// The trampoline-Version of FnDispatcher::Add needs explicit template -// argument specification for type and non-type parameters. Unfortunately -// all workarounds used so far failed for this member-function. -// Therefore I need to use a new one which leads to another interface change: -// Example (see "Modern C++ Design" Section 11.6) -// ---------------------------------------------- -// Using the original one writes: +// Last update: Mar 21, 2003 +// Added a new explicit template argument specification workaround for +// FnDispatcher::Add which is more compliant with other +// explicit template argument specification workarounds used in this port. +// +// Example usage: +// -------------- +// Using the original library one writes: // typedef FnDispatcher Dispatcher; // void Hatch(Rectangle& lhs, Poly& rhs) {...} // // Dispatcher dis; // disp.Add(); // -// Using this port the example becomes: -// Dispatcher::AddI()(dis); +// Using this port the example either becomes: +// dis.Add(Dispatcher::Add()); +// or alternatively +// Dispatcher::AddI()(dis); // // All dispatchers now have void as default value for return types. // All dispatchers now support void as return type. @@ -553,7 +554,52 @@ namespace Private ::Loki::Type2Type()); } - + + // two different workarounds for FnDispatcher::Add + // Using the first one writes: + // DisType dispatcher; + // dispatcher.Add(DisType::Etas()); + // using the second workaround the call becomes: + // DisType dispatcher; + // DisTyp::AddI()(dispatcher); + + // Helper-class for the first workaround. + // When calling FnDispatcher::Add provide an object of this type + // as argument. + template + struct Etas + { + typedef Private::FnDispatcherHelper< + BaseLhs, BaseRhs, SomeLhs, SomeRhs, ResultType, + ApplyInnerType2::type, + ApplyInnerType2::type, + callback> Local; + enum {sym = symmetric}; + typedef SomeLhs Lhs; + typedef SomeRhs Rhs; + }; + + // EtasType has to be a template parameter. If one tries to use + // a parameter of type Etas the MSVC 6.0 won't generate correct + // code. + template + void Add(EtasType EtasObj) + { + typedef typename EtasType::Local Local; + typedef typename EtasType::Lhs SomeLhs; + typedef typename EtasType::Rhs SomeRhs; + + Add(&Local::Trampoline, ::Loki::Type2Type(), + ::Loki::Type2Type()); + if (EtasType::sym) + { + Add(&Local::TrampolineR, ::Loki::Type2Type(), + ::Loki::Type2Type()); + } + } + + // alternative workaround for FnDispatcher::Add template struct AddI @@ -795,6 +841,8 @@ namespace Private // Mar 20. 2003: Fixed Bugs in FnDispatcherHelperBase, FnDispatcher::Add and // FunctorDispatcher::Add. // New Interface for FnDispatcher::Add.B.K. +// Mar 21, 2003: Added new explicit template argument specification workaround +// for FnDispatcher::Add B.K. //////////////////////////////////////////////////////////////////////////////// #endif