Why this
is not allowed in unevaluated context in static member functions?
struct A
{
void f() {}
static void callback(void * self) // passed to C function
{
static_cast< decltype(this) >(self)->f();
}
};
This code gives an error:
error: 'this' is unavailable for static member functions
static_cast< decltype(this) >(self)->f(); ^~~~
decltype(this)
there is needed for brevity (sometimes it is much more shorter, then VeryVeryLongClassName *
), another advantage is the fact that intention is more clear.
What Standard says about using this
in unevaluated contexts in static member functions?