Re: can the member function be compared?
 
"Bill Gates" wrote:
But I found, the code like the following line can be 
compiled
bool fRet = (void*)(&(&Foo::Func1)) < 
(void*)(&(&Foo::Func2));
So we can set a void pointer's value to be the reference 
of the member function like below
void* ptr = ( void* )( &( &Foo::Func1 ) );
Now, I have a question about the pointer ptr. What dose 
the pointer ptr point to?
In the standard, is this defined? (Sorry, I have no C++ 
ISO standard doc)
The value of `ptr' is undefined. Pointer to member is not 
like regular pointer. Think about it as a struct. It can be 
different in size. Moreover, pointer to member may not 
contain an address at all. The only requirement for pointer 
to member is to be able to call class' method via operators 
`.*' and `->*'. Also, it should be comparable to NULL.
I mistakenly assumed in my previous post that pointers to 
member of the _same class_ can be compared one with another 
anyway, since a compiler could infer the real address of 
method's body. However, Igor corrected me.
If you need to distinguish between pointers to member 
function, then you could make arbitrary index for them. Like 
this:
struct X
{
    enum OP { OP_A, OP_B, ... };
    void opA(int param1, int param2);
    void opB(int param1, int param2);
    ...
    typedef std::map<OP, void (X::*)(int, int)> OPMap;
    OPMap m_opMap;
};
Then you could populate the map like this:
m_opMap[OP_A] = &X::opA;
m_opMap[OP_B] = &X::opB;
....
HTH
Alex