From abae0bd998af603d66e929789e054f916cde622b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 19 Feb 2016 19:03:51 +0100 Subject: [PATCH] Refactor is_same_signedness. --- include/gsl_util.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/gsl_util.h b/include/gsl_util.h index 4ac6187..b144108 100644 --- a/include/gsl_util.h +++ b/include/gsl_util.h @@ -91,12 +91,12 @@ inline constexpr T narrow_cast(U u) noexcept struct narrowing_error : public std::exception {}; -template -struct is_same_signess +namespace details { - static const bool value = - std::is_signed::value == std::is_signed::value; -}; + template + struct is_same_signedness : public std::integral_constant::value == std::is_signed::value> + {}; +} // narrow() : a checked version of narrow_cast() that throws if the cast changed the value template @@ -105,7 +105,7 @@ inline T narrow(U u) T t = narrow_cast(u); if (static_cast(t) != u) throw narrowing_error(); - if (!is_same_signess::value && ((t < T{}) != (u < U{}))) + if (!details::is_same_signedness::value && ((t < T{}) != (u < U{}))) throw narrowing_error(); return t; }