【发布时间】:2010-12-06 05:27:07
【问题描述】:
加入 SO 后,每当我打开讨论模板的主题时,我都会经常看到这种语法。我尝试在谷歌上搜索,但徒劳无功。
template<typename T>
char (&f(T[1]))[1]; //what is it? what is the use of '[]' brackets and the integer in it?
template<typename T>
char (&f(...))[2]; //not this either
int main() { char c[sizeof(f<void()>(0)) == 2]; } // and this?
从这里:SFINAE with invalid function-type or array-type parameters?
请解释我放置 cmets 的 3 行。我特别想了解语法。我们可以只在模板中使用这样的语法吗?
【问题讨论】: