View Single Post
  #3 (permalink)  
Old 07-07-2008, 01:40 PM
G_Morgan G_Morgan is offline
Guru
 
Join Date: Oct 2007
Age: 24
Posts: 473
Last Blog:
Just over the next hil...
Rep Power: 10
G_Morgan has a spectacular aura aboutG_Morgan has a spectacular aura aboutG_Morgan has a spectacular aura about
Default Re: C++ - function pointers as a static data member.

I'm not returning a pointer to a private function. I have a function pointer as a private static data member.

The cGetLength function is the implementation (in plain C/C++). The argument v to cGetLength is being used in place of the this pointer (note that the implementation has one more variable than the inlined method that calls the function pointer). Eventually there will be an sseGetLength and possibly an amd3DNowGetLength. Also an initGetLength which calls my CPU testing code on the first run and picks the appropriate implementation for future calls.

I actually solved this about 45 minutes ago by altering the declaration*. Apparently there's a mess in C++ what's a member function pointer and what's a normal function pointer. What I've defined there is the former when it needs to be the latter. It passes the test suite now so either god is fiddling the values or it works.

* float (*O3DMVector::getLengthPtr)(O3DMVector &) = &cGetLength;
Reply With Quote