This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ function pointers and automatic class refrences
- From: Matthijs van Duin <matthijs at cds dot nl>
- To: "Mason, Sam" <smason at mtc dot ricardo dot com>, gcc at gcc dot gnu dot org
- Date: Wed, 22 May 2002 21:07:27 +0200
- Subject: Re: C++ function pointers and automatic class refrences
- References: <20020522085639.GA31976@mtc.ricardo.com>
>Well what I'm trying to do is get something like C function pointers
>but with a reference to an object included so I don't have to use
>static functions.
you can use templates, like:
template<class T> void my_proc(void (T::*proc)());
to see an example, here's a piece of code I once wrote: (WARNING: the
code is ugly and evil, it was designed to annoy the lab assistant ;-)
http://www.nubz.org/btree.h.txt
BTreeNode::Edit is a good example, it works over a path and does a
callback for each node
(maybe a good test-case, with all the nested template crap. I recall
I originally had a version which caused gcc to ICE, but I this
version doesn't, and I can't remember what was different..)
- xmath
Matthijs van Duin (NOTE: PGP key has changed!)
- PGP Key: 0x2D6F0BA7
- FP: 205D F7BA FFAD 9070 AB9E C5A8 BDB0 CA1B 2D6F 0BA7 -