Why it's forbidden to capture non-type template parameters in the lambda capture list?
The following code fails to compile on both GCC and clang:
template<int x>
auto foo()
{
return [x]{return x;};
}
with an error message capture of non-variable 'x' on GCC and 'x' in capture list does not name a variable on clang.
... however, the following code compiles fine:
template<int x>
auto bar()
{
return [y = x]{return y;};
}