#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;
}
decltype
λ 형식을 사용할 때 사용할 형식은 무엇입니까? 코드가 독점적으로 반복자를 기대 나타나는 그러나, 아마 허용의템플릿과 람다 문제 C++ 0x
무엇이 오류입니까? 그것은 여기에 잘 실행 중입니다 : http://ideone.com/zI3iL – Naveen
그 오류가 없습니다, 그냥 템플릿과 함께 람다를 사용하여 궁금해하는 경우, 람다에게 템플릿의 유형을 알려주는 유일한 방법은 올바른 것입니다 코드하는 방법? – hidayat