jjzjj

CPowerOfTen

全部标签

c++ - 当模板化类不包含可用的成员函数时,如何在编译时验证模板参数?

我有以下模板化结构:templatestructCPowerOfTen{enum{Value=10*CPowerOfTen::Value};};templatestructCPowerOfTen{enum{Value=1};};这样使用:constintNumberOfDecimalDigits=5;constintMaxRepresentableValue=CPowerOfTen::Value-1;//nowcanusebothconstantssafely-they'resurelyinsync现在该模板要求Degree为非负数。我想为此强制执行编译时断言。我该怎么做?我试图向CP