Understanding gsl::narrow implementation
问题 The C++ Core Guidelines has a narrow cast that throws if the cast changes the value. Looking at the microsoft implementation of the library: // narrow() : a checked version of narrow_cast() that throws if the cast changed the value template <class T, class U> T narrow(U u) noexcept(false) { T t = narrow_cast<T>(u); if (static_cast<U>(t) != u) gsl::details::throw_exception(narrowing_error()); if (!details::is_same_signedness<T, U>::value && ((t < T{}) != (u < U{}))) // <-- ??? gsl::details: