What unqualifies capturing lambda from being passed to apply
method of std::valarray
?
consider following code:
int main()
{
std::valarray<int> arr = {1, 2, 3, 4, 5, 6};
auto arr1 = arr.apply([](int val) { return val * 2; }); // compiles
int n = 3;
auto arr2 = arr.apply([n](int val) { return val * n; }); //does not compile
return 0;
}
Live on coliru http://coliru.stacked-crooked.com/a/f0407046699574fc
Tested on https://gcc.godbolt.org/
Neither GCC nor MSVC or CLang would compile the above code