diff --git a/include/gsl/gsl_util b/include/gsl/gsl_util index cdb94ac..19e4831 100644 --- a/include/gsl/gsl_util +++ b/include/gsl/gsl_util @@ -109,12 +109,12 @@ constexpr #endif T narrow(U u) noexcept(false) { - constexpr const bool is_same_signedness = std::is_signed::value == std::is_signed::value; + constexpr const bool is_different_signedness = (std::is_signed::value != std::is_signed::value); const T t = narrow_cast(u); if (static_cast(t) != u - || (!is_same_signedness + || (is_different_signedness && ((t < T{}) != (u < U{})))) { throw narrowing_error{};