So as far as this pointer (struct a_class *const this) is not used inside member function a_class::mem_func (mangled as _ZN7a_class8mem_funcEv) this code will work (provided the compiler generates such code. Most (all that I know of) of the compiler choose to implement member function call as shown above.)
> So as far as this pointer is not used inside member function
if the state of the object is not modified or used, then it shouldn't be a member function.
If a class is empty, is it safe, or is it undefined, to cast to it from a nullptr and call member functions?
Yes, it is safe...A null pointer is a regular pointer of any pointer type which has a special value that indicates that it is not pointing to any valid reference or memory address. This value is the result of type-casting the integer value zero to any pointer type.
JLBorges hit the snail on the head. I was just curious if there was an easier way than doing some convoluted stuff with a static global instance. This thread is a spin-off of Catfish's thread.