Remove FloatingPoint::Max() in favor of std::numeric_limits::max()
In #4113 a user says Max clashes with a macro. Since it is only used in a test, use std::numeric_limits::max() instead. Note that in headers, the macro issue can be mitigated with parenthesis like this: `(std::numeric_limits<T>::max)()` PiperOrigin-RevId: 504284906 Change-Id: Ibf430caec1a6afdf6b303534fec6a4fd00a6373f
This commit is contained in:
parent
ec25eea8f8
commit
544c96ed5b
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
#include "test/gmock-matchers_test.h"
|
#include "test/gmock-matchers_test.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
namespace gmock_matchers_test {
|
namespace gmock_matchers_test {
|
||||||
namespace {
|
namespace {
|
||||||
@ -1037,7 +1039,7 @@ class FloatingPointTest : public testing::Test {
|
|||||||
Floating::ReinterpretBits(infinity_bits_ - max_ulps_)),
|
Floating::ReinterpretBits(infinity_bits_ - max_ulps_)),
|
||||||
further_from_infinity_(
|
further_from_infinity_(
|
||||||
Floating::ReinterpretBits(infinity_bits_ - max_ulps_ - 1)),
|
Floating::ReinterpretBits(infinity_bits_ - max_ulps_ - 1)),
|
||||||
max_(Floating::Max()),
|
max_(std::numeric_limits<RawType>::max()),
|
||||||
nan1_(Floating::ReinterpretBits(Floating::kExponentBitMask | 1)),
|
nan1_(Floating::ReinterpretBits(Floating::kExponentBitMask | 1)),
|
||||||
nan2_(Floating::ReinterpretBits(Floating::kExponentBitMask | 200)) {}
|
nan2_(Floating::ReinterpretBits(Floating::kExponentBitMask | 200)) {}
|
||||||
|
|
||||||
|
@ -307,9 +307,6 @@ class FloatingPoint {
|
|||||||
// Returns the floating-point number that represent positive infinity.
|
// Returns the floating-point number that represent positive infinity.
|
||||||
static RawType Infinity() { return ReinterpretBits(kExponentBitMask); }
|
static RawType Infinity() { return ReinterpretBits(kExponentBitMask); }
|
||||||
|
|
||||||
// Returns the maximum representable finite floating-point number.
|
|
||||||
static RawType Max();
|
|
||||||
|
|
||||||
// Non-static methods
|
// Non-static methods
|
||||||
|
|
||||||
// Returns the bits that represents this number.
|
// Returns the bits that represents this number.
|
||||||
@ -390,17 +387,6 @@ class FloatingPoint {
|
|||||||
FloatingPointUnion u_;
|
FloatingPointUnion u_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// We cannot use std::numeric_limits<T>::max() as it clashes with the max()
|
|
||||||
// macro defined by <windows.h>.
|
|
||||||
template <>
|
|
||||||
inline float FloatingPoint<float>::Max() {
|
|
||||||
return FLT_MAX;
|
|
||||||
}
|
|
||||||
template <>
|
|
||||||
inline double FloatingPoint<double>::Max() {
|
|
||||||
return DBL_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Typedefs the instances of the FloatingPoint template class that we
|
// Typedefs the instances of the FloatingPoint template class that we
|
||||||
// care to use.
|
// care to use.
|
||||||
typedef FloatingPoint<float> Float;
|
typedef FloatingPoint<float> Float;
|
||||||
|
Loading…
Reference in New Issue
Block a user