This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ function pointers and automatic class refrences


>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 -


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]