Why is operator ()
of stateless functor not allowed to be static
? Stateless lambda objects are convertible to pointers to free functions having the same signature as their operator ()
.
Stephan T. Lavavej on p. 6 points out that conversion to a function pointer is just an operator FunctionPointer()
(cite). But I can't obtain a corresponding pointer to operator ()
as to non-member function. For functor struct F { void operator () () {} }
it seems to be impossible to convert &F::operator ()
to instance of type using P = void (*)();
.
Code:
struct L
{
static
void operator () () const {}
operator auto () const
{
return &L::operator ();
}
};
The error is
overloaded 'operator()' cannot be a static member function
but operator ()
is not overloaded.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…