Use the c++17 constexpr if in CheckRange if possible (#753)

* change c++17 to use constexpr if in CheckRange

* remove unnecessary macro

* use the portable feature test macro rather than direct version check
This commit is contained in:
kile0 2018-11-28 11:52:11 -08:00 committed by Anna Gringauze
parent b673375719
commit 5a7093f983

View File

@ -556,7 +556,11 @@ private:
// wrap around to a value always greater than size when casted. // wrap around to a value always greater than size when casted.
// check if we have enough space to wrap around // check if we have enough space to wrap around
#if defined(__cpp_if_constexpr)
if constexpr (sizeof(index_type) <= sizeof(size_t))
#else
if (sizeof(index_type) <= sizeof(size_t)) if (sizeof(index_type) <= sizeof(size_t))
#endif
{ {
return narrow_cast<size_t>(idx) < narrow_cast<size_t>(size); return narrow_cast<size_t>(idx) < narrow_cast<size_t>(size);
} }