fully qualify ptrdiff_t in multi_span and remove it from gsl\gsl

This commit is contained in:
Jordan Maples 2020-04-21 16:14:58 -07:00
parent 9f6a9a5807
commit afa2f3fd9a
2 changed files with 5 additions and 6 deletions

View File

@ -21,7 +21,6 @@
#include <gsl/gsl_assert> // Ensures/Expects #include <gsl/gsl_assert> // Ensures/Expects
#include <gsl/gsl_byte> // byte #include <gsl/gsl_byte> // byte
#include <gsl/gsl_util> // finally()/narrow()/narrow_cast()... #include <gsl/gsl_util> // finally()/narrow()/narrow_cast()...
#include <gsl/multi_span> // multi_span, strided_span...
#include <gsl/pointers> // owner, not_null #include <gsl/pointers> // owner, not_null
#include <gsl/span> // span #include <gsl/span> // span
#include <gsl/string_span> // zstring, string_span, zstring_builder... #include <gsl/string_span> // zstring, string_span, zstring_builder...

View File

@ -23,7 +23,7 @@
#include <algorithm> // for transform, lexicographical_compare #include <algorithm> // for transform, lexicographical_compare
#include <array> // for array #include <array> // for array
#include <cstddef> // for ptrdiff_t, size_t, nullptr_t #include <cstddef> // for std::ptrdiff_t, size_t, nullptr_t
#include <cstdint> // for PTRDIFF_MAX #include <cstdint> // for PTRDIFF_MAX
#include <functional> // for divides, multiplies, minus, negate, plus #include <functional> // for divides, multiplies, minus, negate, plus
#include <initializer_list> // for initializer_list #include <initializer_list> // for initializer_list
@ -62,7 +62,7 @@
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif #endif
// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) // GCC 7 does not like the signed unsigned missmatch (size_t std::ptrdiff_t)
// While there is a conversion from signed to unsigned, it happens at // While there is a conversion from signed to unsigned, it happens at
// compiletime, so the compiler wouldn't have to warn indiscriminently, but // compiletime, so the compiler wouldn't have to warn indiscriminently, but
// could check if the source value actually doesn't fit into the target type // could check if the source value actually doesn't fit into the target type
@ -392,9 +392,9 @@ namespace details
template <typename T, std::size_t Dim = 0> template <typename T, std::size_t Dim = 0>
constexpr size_type contains(const T& arr) const constexpr size_type contains(const T& arr) const
{ {
const ptrdiff_t last = this->Base::template contains<T, Dim + 1>(arr); const std::ptrdiff_t last = this->Base::template contains<T, Dim + 1>(arr);
if (last == -1) return -1; if (last == -1) return -1;
const ptrdiff_t cur = this->Base::totalSize() * arr[Dim]; const std::ptrdiff_t cur = this->Base::totalSize() * arr[Dim];
return cur < m_bound ? cur + last : -1; return cur < m_bound ? cur + last : -1;
} }
@ -462,7 +462,7 @@ namespace details
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
Expects(arr[Dim] >= 0 && arr[Dim] < CurrentRange); // Index is out of range Expects(arr[Dim] >= 0 && arr[Dim] < CurrentRange); // Index is out of range
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
const ptrdiff_t d = arr[Dim]; const std::ptrdiff_t d = arr[Dim];
return this->Base::totalSize() * d + this->Base::template linearize<T, Dim + 1>(arr); return this->Base::totalSize() * d + this->Base::template linearize<T, Dim + 1>(arr);
} }