fix __cplusplus check for MSVC
Because of an MSVC bug, __cplusplus is always 199711L. Use _MSVC_LANG which gets set properly. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
f515799a53
commit
b31b4abbaf
@ -1270,7 +1270,7 @@ class ValueType : public Value {
|
||||
}
|
||||
|
||||
// Check for integer overflow.
|
||||
#if __cplusplus >= 201703L
|
||||
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
|
||||
if constexpr (std::is_signed_v<I> == std::is_signed_v<decltype(a)>) {
|
||||
#else
|
||||
if (std::is_signed<I>::value == std::is_signed<decltype(a)>::value) {
|
||||
@ -1281,13 +1281,13 @@ class ValueType : public Value {
|
||||
if (imax < b || a < imin || imax < a) {
|
||||
return 0;
|
||||
}
|
||||
#if __cplusplus >= 201703L
|
||||
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
|
||||
} else if constexpr (std::is_signed_v<I>) {
|
||||
#else
|
||||
} else if (std::is_signed<I>::value) {
|
||||
#endif
|
||||
// conversion is from unsigned to signed
|
||||
#if __cplusplus >= 201402L
|
||||
#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L
|
||||
const auto imax = static_cast<std::make_unsigned_t<I>>(std::numeric_limits<I>::max());
|
||||
#else
|
||||
const auto imax = static_cast<typename std::make_unsigned<I>::type>(std::numeric_limits<I>::max());
|
||||
@ -1302,7 +1302,7 @@ class ValueType : public Value {
|
||||
return 0;
|
||||
}
|
||||
// Inputs are not negative so convert them to unsigned.
|
||||
#if __cplusplus >= 201402L
|
||||
#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L
|
||||
const auto a_u = static_cast<std::make_unsigned_t<decltype(a)>>(a);
|
||||
const auto b_u = static_cast<std::make_unsigned_t<decltype(b)>>(b);
|
||||
#else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user