Can lambdas be used as non-type template parameter?
问题 Is the following code legal? template <auto Lambda> struct A {}; int main () { auto lmb = [](int i){return i*i;}; A<lmb> a; return 0; } I noticed that g++ compiles it fine, while clang++ returns error: a non-type template parameter cannot have type '(lambda at main.cpp:...)' . 回答1: Can lambdas be used as non-type template parameter? Yes, with implementations that has implemented P0732R2 - Class types in non-type template parameters but clang++ has not implemented it yet. Source: https://en