Click here to Skip to main content
15,885,309 members
Articles / Programming Languages / ASM

Member Function Pointers and the Fastest Possible C++ Delegates

Rate me:
Please Sign up or sign in to vote.
4.83/5 (720 votes)
5 Apr 2005CPOL49 min read 2.6M   25K   915  
A comprehensive tutorial on member function pointers, and an implementation of delegates that generates only two ASM opcodes!
SOME HELPER TOOLS USED IN CREATING THE FASTDELEGATE LIBRARY

They are not very impressive, and are included only for completeness.

A. HOW TO CREATE FASTDELEGATE.H

1. Compile Hopter.cpp to form Hopter.exe
2. On the command line, type:
HOPTER FastDelegate.hxx FastDelegate.h

An explanation of what the program does is in Hopter.cpp.

B. TEST FILE USED TO DISCOVER MFP REPRESENTATION

If you have a compiler not listed in the article, compile
the 'memfuntest.cpp' file to an asm listing.
For example, with GCC you would type:

g++ -S memfuntest.cpp

Email the asm file to me.

Thanks for your interest!
-Don Clugston, 4 Nov 2004.


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Germany Germany
I'm an Australian physicist/software engineer living in Leipzig, Germany. I've published papers about windows (the glass kind), semiconductor device physics, environmental philosophy and theology, vacuum systems, and now (at CodeProject) the innards of C++. (Yes, my C.V. is a terrible mess.) I'm a major contributor to the D programming language. I can read New Testament Greek, and can speak German with a dreadful accent.

I have one wife, one son (pictured), and one daughter, who are all much cuter than I am.

"The light shines in the darkness, but the darkness has not overcome it."

Comments and Discussions