C++20: Non-capturing lambda in non-type template parameter
问题 Does C++20 allow a non-capturing lambda decayed to a function pointer to be passed directly as a non-type template parameter? If so, what is the correct syntax? I have tried the following code in various versions of clang and gcc using -std=c++2a . #include <iostream> template<auto f> struct S { static void invoke(int x) { f(x); } }; using X = S<+[](int x) -> void { std::cout << x << " hello\n"; }>; int main() { X::invoke(42); } gcc compiles the code without complaint and the code runs as