I found an interesting gotcha with std::numeric_limits
returning 0. The answer is to use seconds::max()
or std::numeric_lim
std::numeric_limits
is not specialized for std::chrono::seconds
. Default definitions are given for all data members and functions in std::numeric_limits
to avoid compiler errors for unspecialized types. The default version of numeric_limits
simply returns T()
, which is 0
in this case.
You can check if std::numeric_limits
is specialized for a given T
at compile time by checking std::numeric_limits
, which defaults to false
.