decltype 关键字
decltype 关键字会保留一个类型的所有信息
const int i = 0;//decltype(i)->const int
bool f(const Widget&w);//decltype(f)-> bool (const Widget&);
//decltype(f(w))->bool
struct Point{
int x,y;
}
利用decltype
实现函数返回值的类型推导(c++11)
template<typename Container,typename Index>
auto authAndAccess(Container &c,Index i)->dectype(c[i])
{
authenticateUser();
return c[i];
}