std :: numeric_limits提供了2个互斥的常量:
> is_integer
:“对于所有整数算术类型T都为真”
> is_exact
:“对于使用精确表示的所有算术类型T都是如此”
解决方法
从
is_exact
cppreference页面:
Notes
While all fundamental types T for which
std::numeric_limits<T>::is_exact==true
are integer types,a library
may define exact types that aren’t integers,e.g. a rational
arithmetics type representing fractions.
而且,正如@Holt所提到的,该标准也描述了它:
21.3.4.1 numeric_limits members [numeric.limits.members]
static constexpr bool is_exact;
true if the type uses an exact representation. All integer types are exact,but not all exact types are integer. For example,rational and fixed-exponent representations are exact but not integer.