This template function does not recognize the lamda's returned type, even specifing it decommenting '->void'.
Why does it happen?
What could I do to circumvent this problem?
#include<iostream>
#include<array>
template<typename T, typename S, size_t SIZE>
void for_each(std::array<T,SIZE>& arr, S(*func)(int&))
{
for (auto i{0}; i != arr.size(); ++i)
func(arr[i]);
}
int main()
{
std::array<int, 5> five_elems{10, 20, 30, 40, 50};
for_each(five_elems, [](int& ref)/*->void*/{ref *= 2; std::cout << ref << ' '; });
//for (auto i : five_elems)
// i*=2;
for (const auto i : five_elems)
std::cout << i << ' ';
}