Click here to Skip to main content
15,893,588 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: vector of template class Pin
Aescleal18-Aug-10 11:11
Aescleal18-Aug-10 11:11 
GeneralRe: vector of template class Pin
forwardsim18-Aug-10 11:02
forwardsim18-Aug-10 11:02 
AnswerRe: vector of template class Pin
Niklas L18-Aug-10 10:30
Niklas L18-Aug-10 10:30 
GeneralRe: vector of template class [modified] Pin
forwardsim18-Aug-10 10:54
forwardsim18-Aug-10 10:54 
GeneralRe: vector of template class Pin
Aescleal18-Aug-10 11:40
Aescleal18-Aug-10 11:40 
GeneralRe: vector of template class Pin
forwardsim18-Aug-10 12:22
forwardsim18-Aug-10 12:22 
GeneralRe: vector of template class Pin
Aescleal18-Aug-10 22:15
Aescleal18-Aug-10 22:15 
GeneralRe: vector of template class Pin
Emilio Garavaglia18-Aug-10 22:23
Emilio Garavaglia18-Aug-10 22:23 
You are running on a complex thing (for C++) generically named as "mumtimethod".

C++ function dispatching works with v-tables only for the one and only implicit parameter of a virtual member function (this).

If you need to dispatch based on two parameters (that is: when not only the object type but also a function parameter is important) you need to go across two indirections. And since V-tables holds only one you have to workaround.

There are various articles about "multimethods" (try google with that key) with different approaches, but they always have to fall into two indirections, two switches, one swith and one indirection etc.

The complexity of the coding process will be in any case N2 (you have to supply implementation for all the combination) and the execution complexity (whatever you use V-function of switches) will always be "two indrections".

My invite is to don't drop solution only becasue they use virtual function or because they use dynamic_cast: the fact that such implemetations are always slower is a mith: they are slower than direct calls, but where indirections are needed, they are fast exactly like whatever other indirection mechanism. If you define a vector of function pointer to dispatch the calls ... like many of those article, with more or less smart or complex way do, you are implementing in source a v-table!

2 bugs found.
> recompile ...
65534 bugs found.
D'Oh! | :doh:


GeneralRe: vector of template class Pin
forwardsim19-Aug-10 4:44
forwardsim19-Aug-10 4:44 
AnswerRe: vector of template class Pin
Niklas L19-Aug-10 2:23
Niklas L19-Aug-10 2:23 
GeneralRe: vector of template class Pin
Aescleal19-Aug-10 3:01
Aescleal19-Aug-10 3:01 
GeneralRe: vector of template class Pin
Niklas L19-Aug-10 3:16
Niklas L19-Aug-10 3:16 
GeneralRe: vector of template class Pin
forwardsim19-Aug-10 4:47
forwardsim19-Aug-10 4:47 
GeneralRe: vector of template class Pin
Aescleal19-Aug-10 6:24
Aescleal19-Aug-10 6:24 
GeneralRe: vector of template class Pin
Niklas L19-Aug-10 8:29
Niklas L19-Aug-10 8:29 
GeneralRe: vector of template class [modified] Pin
Paul Michalik20-Aug-10 2:03
Paul Michalik20-Aug-10 2:03 
GeneralRe: vector of template class Pin
Niklas L20-Aug-10 2:22
Niklas L20-Aug-10 2:22 
GeneralRe: vector of template class Pin
Paul Michalik20-Aug-10 4:06
Paul Michalik20-Aug-10 4:06 
Questioncan main() be overloaded?? Pin
AmbiguousName18-Aug-10 6:36
AmbiguousName18-Aug-10 6:36 
AnswerRe: can main() be overloaded?? Pin
Aescleal18-Aug-10 6:50
Aescleal18-Aug-10 6:50 
QuestionRe: can main() be overloaded?? Pin
David Crow18-Aug-10 9:14
David Crow18-Aug-10 9:14 
AnswerRe: can main() be overloaded?? Pin
Aescleal18-Aug-10 10:00
Aescleal18-Aug-10 10:00 
GeneralRe: can main() be overloaded?? Pin
David Crow18-Aug-10 10:21
David Crow18-Aug-10 10:21 
GeneralRe: can main() be overloaded?? Pin
Aescleal18-Aug-10 10:26
Aescleal18-Aug-10 10:26 
GeneralRe: can main() be overloaded?? Pin
David Crow18-Aug-10 10:35
David Crow18-Aug-10 10:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.