Lambda function (or closure) in C++ is just an unnamed function object with operator (). But what is the return type of that operator? The question becomes important if one wishes explicitly reference the full type of the operator e.g. for declaring it a friend.
For example, return type auto:
using V = decltype([](){});
class A{
friend constexpr auto V::operator()() const;
};
int main(){
V{}();
}
is accepted by Clang/MSVC but not GCC, demo: https://gcc.godbolt.org/z/9fdzG94oK
And GCC requires friend declaration with deduced void return type here:
friend constexpr void V::operator()() const;
which is in turn rejected by Clang/MSVC, demo: https://gcc.godbolt.org/z/naKaavndj
Which compiler is right here?