Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在模板函数中,我喜欢确定其模板类型值的范围。对于特定类型,如 int,INT_MAX 和 INT_MIN 是我想要的。但是如何对模板类型做同样的事情呢?
谢谢并恭祝安康!
对于数字类型,您可以在标题中使用std::numeric_limits类模板。<limits>
std::numeric_limits
<limits>
这是通过类型特征完成的,例如来自 boost
请参阅<limits>标头和std::numeric_limits