www.digitalmars.com         C & C++   DMDScript  

c++ - Member Function Pointers and the Fastest Possible C++ Delegates

reply Don Clugston <Don_member pathlink.com> writes:
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
Jan 12 2005
next sibling parent Anonymous <Anonymous_member pathlink.com> writes:
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

Jan 12 2005
prev sibling next sibling parent reply John Reimer <brk_6502 yahoo.com> writes:
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

Jan 14 2005
parent Don Clugston <Don_member pathlink.com> writes:
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


Jan 19 2005
prev sibling parent "Walter" <newshound digitalmars.com> writes:
It really is an excellent article. Thanks!
Feb 26 2005