Here's a small snippet of code:
template<void(*)()> struct s{};
int main() {
s<+[]{}> t;
}
I'm trying to take the pointer to the function of the lambda. It compiles in clang but GCC rejects it:
main.cpp:5:8: error: lambda-expression in template-argument
s<+[]{}> t; ^
main.cpp:5:12: error: template argument 1 is invalid
s<+[]{}> t; ^
The following code compiles with both GCC and clang:
template<void(*)()> struct s{};
constexpr auto f = +[]{};
int main() {
s<f> t;
}
Which compiler is right and why?