mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Fix max
macro collision (#1081)
PR https://github.com/microsoft/GSL/pull/1076 introduced a usage of `numeric_limits::max()` function, which seems to have [issues interacting with some Windows headers](https://github.com/skypjack/entt/wiki/Frequently-Asked-Questions#warning-c4003-the-min-the-max-and-the-macro). This PR implements [a simple fix](https://stackoverflow.com/questions/1394132/macro-and-member-function-conflict), which is to wrap the invocations in parentheses. This offloads the fix from the users of the library.
This commit is contained in:
parent
a381a3759f
commit
cbf5e664fc
@ -111,7 +111,7 @@ GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
constexpr T& at(T (&arr)[N], const index i)
|
constexpr T& at(T (&arr)[N], const index i)
|
||||||
{
|
{
|
||||||
static_assert(N <= static_cast<std::size_t>(std::numeric_limits<std::ptrdiff_t>::max()), "We only support arrays up to PTRDIFF_MAX bytes.");
|
static_assert(N <= static_cast<std::size_t>((std::numeric_limits<std::ptrdiff_t>::max)()), "We only support arrays up to PTRDIFF_MAX bytes.");
|
||||||
Expects(i >= 0 && i < narrow_cast<index>(N));
|
Expects(i >= 0 && i < narrow_cast<index>(N));
|
||||||
return arr[narrow_cast<std::size_t>(i)];
|
return arr[narrow_cast<std::size_t>(i)];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user