Search code examples
c++functionpointersfunction-pointersself-reference

C++ function pointer to self


Is there a way to have a function pointer to the function that's getting it. It should work like this:

void foo()
{
        assert(<self-pointer> == &foo);
}

(moved form comment):
I want a macro that can log something and add the place where the log came from to it. For this I want to use an id, which I thought I could make the function's pointer.


Solution

  • There are no equivalent of this (about class instance) for function/method.