你将如何在一个std::enable_if?中使用非类型模板参数比较?我无法弄清楚如何再次这样做.(我曾经有过这个工作,但是我丢失了代码,所以我无法回头看看,而且我找不到帖子,我找到了答案.)
提前感谢您对此主题的任何帮助.
template<int Width, int Height, typename T>
class Matrix{
static
typename std::enable_if<Width == Height, Matrix<Width, Height, T>>::type
Identity(){
Matrix ret;
for (int y = 0; y < Width; y++){
elements[y][y] = T(1);
}
return ret;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:修复了注释中指出的缺失括号.