#include <iostream>
#include <algorithm>
#include <array>
using namespace std;
template<class T>
void func(T beg, T end)
{
typedef decltype(*beg) type;
std::for_each(beg, end, [](type t) { cout << t << endl; });
}
int main()
{
std::array<int, 4> arr = { 1,2,3,4 };
func(arr.begin(), arr.end());
return 0;
}
Is decltype the way to go when telling the lambda expression what type is going to use?