Why is C++ numeric_limits::max() == 0?

前端 未结 4 825
忘了有多久
忘了有多久 2021-01-04 06:22

Here\'s a bit of code that might seem like it would work:

#include 
#include 

enum test { A = 1 };

int main()
{
    int max =          


        
4条回答
  •  既然无缘
    2021-01-04 07:07

    For non-specialized versions of the template, max returns T(). You have not written a numeric_limits specialization for your test type, so you get the default implementation.

提交回复
热议问题