Thread overview
Member Function Pointers and the Fastest Possible C++ Delegates
Jan 13, 2005
Don Clugston
Jan 13, 2005
Anonymous
Jan 14, 2005
John Reimer
Jan 20, 2005
Don Clugston
Feb 26, 2005
Walter
January 13, 2005
Below is an article I have written which may be of interest to many on this group:

"Member Function Pointers and the Fastest Possible C++ Delegates"

A comprehensive tutorial on member function pointers, and an implementation of delegates that generates only two ASM opcodes!

http://www.codeproject.com/cpp/FastDelegate.asp


It provides an in-depth exploration of exactly how each of the major compiler vendors implement member function pointers. Most of this has never been documented previously. Digital Mars comes out as a clear winner. Walter, you may be amused by the discussion of how badly Microsoft botched it :)

This clandestine information is then used to create delegates similar to Borland C++'s __closure pointers or D delegates, that work on all C++ compilers in common use, and generate optimal asm code for most of them. (Unlike some other implementations, it also works for static function pointers). It is currently being used in commercial software on several different architectures, with several different compilers.

The article has been extremely popular, and I know several people are using DMC after first hearing of it there. I'm doing my bit to advertise DMC!

If you find any errors in the article (particularly in the compiler discussion),
please let me know.

-Don



January 13, 2005
Great article!

In article <cs4u65$18ic$1@digitaldaemon.com>, Don Clugston says...
>
>Below is an article I have written which may be of interest to many on this group:
>
>"Member Function Pointers and the Fastest Possible C++ Delegates"
>
>A comprehensive tutorial on member function pointers, and an implementation of delegates that generates only two ASM opcodes!
>
>http://www.codeproject.com/cpp/FastDelegate.asp
>
>
>It provides an in-depth exploration of exactly how each of the major compiler vendors implement member function pointers. Most of this has never been documented previously. Digital Mars comes out as a clear winner. Walter, you may be amused by the discussion of how badly Microsoft botched it :)
>
>This clandestine information is then used to create delegates similar to Borland C++'s __closure pointers or D delegates, that work on all C++ compilers in common use, and generate optimal asm code for most of them. (Unlike some other implementations, it also works for static function pointers). It is currently being used in commercial software on several different architectures, with several different compilers.
>
>The article has been extremely popular, and I know several people are using DMC after first hearing of it there. I'm doing my bit to advertise DMC!
>
>If you find any errors in the article (particularly in the compiler discussion),
>please let me know.
>
>-Don
>
>
>


January 14, 2005
Um... Wow!  I don't usually spend my time reading articles on C++, but that one was well worth the read.  It wasn't just informative; it was well-written and non-cryptic -- a rare find in a high-tech world, especially in the C++ world.

It certainly made me appreciate D, though.

Thanks, Don.

- John

On Thu, 13 Jan 2005 04:41:41 +0000, Don Clugston wrote:

> Below is an article I have written which may be of interest to many on this group:
> 
> "Member Function Pointers and the Fastest Possible C++ Delegates"
> 
> A comprehensive tutorial on member function pointers, and an implementation of delegates that generates only two ASM opcodes!
> 
> http://www.codeproject.com/cpp/FastDelegate.asp
> 
> 
> It provides an in-depth exploration of exactly how each of the major compiler vendors implement member function pointers. Most of this has never been documented previously. Digital Mars comes out as a clear winner. Walter, you may be amused by the discussion of how badly Microsoft botched it :)
> 
> This clandestine information is then used to create delegates similar to Borland C++'s __closure pointers or D delegates, that work on all C++ compilers in common use, and generate optimal asm code for most of them. (Unlike some other implementations, it also works for static function pointers). It is currently being used in commercial software on several different architectures, with several different compilers.
> 
> The article has been extremely popular, and I know several people are using DMC after first hearing of it there. I'm doing my bit to advertise DMC!
> 
> If you find any errors in the article (particularly in the compiler discussion),
> please let me know.
> 
> -Don

January 20, 2005
>Um... Wow!  I don't usually spend my time reading articles on C++, but that one was well worth the read.  It wasn't just informative; it was well-written and non-cryptic -- a rare find in a high-tech world, especially in the C++ world.

Thanks, John. High praise indeed.

>It certainly made me appreciate D, though.

The first draft of the article included the word "scandal" in the title ;-).
I have a love-hate relationship with C++. There are so many things wrong with
it, but it's still much better than the alternatives. D is rapidly closing the
gap, though.
My impression is:
D is a cleaned-up C++ created by someone who understands C++.
C# is a cleaned-up C++ created by people who don't understand C++. (And uses a
virtual machine that's *less* powerful than the real machine it's running on???
(eg long double) You've got to be kidding).
Unfortunately, Walter has a lot less influence than Microsoft.

-Don

>On Thu, 13 Jan 2005 04:41:41 +0000, Don Clugston wrote:
>
>> Below is an article I have written which may be of interest to many on this group:
>> 
>> "Member Function Pointers and the Fastest Possible C++ Delegates"
>> 
>> A comprehensive tutorial on member function pointers, and an implementation of delegates that generates only two ASM opcodes!
>> 
>> http://www.codeproject.com/cpp/FastDelegate.asp
.. etc


February 26, 2005
It really is an excellent article. Thanks!