From 17ad4495fbde91a325d765883b1c27b119b37607 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Fri, 13 Dec 2019 13:40:25 -0800 Subject: [PATCH] deprecate gsl::details::throw_exception. remove unused header in gsl_assert. gsl_util to use terminate instead of throw_exception --- include/gsl/gsl_assert | 3 +-- include/gsl/gsl_util | 9 ++------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/gsl/gsl_assert b/include/gsl/gsl_assert index c707030..7a9e8ad 100644 --- a/include/gsl/gsl_assert +++ b/include/gsl/gsl_assert @@ -18,7 +18,6 @@ #define GSL_CONTRACTS_H #include -#include // for logic_error // // make suppress attributes parse for some compilers @@ -111,8 +110,8 @@ namespace details #endif } - template + [[deprecated("GSL no longer supports throwing for contract violations. Use gsl::details::terminate() instead.")]] [[noreturn]] void throw_exception(Exception&&) noexcept { gsl::details::terminate(); diff --git a/include/gsl/gsl_util b/include/gsl/gsl_util index e4b2daa..d1f7f33 100644 --- a/include/gsl/gsl_util +++ b/include/gsl/gsl_util @@ -21,7 +21,6 @@ #include #include // for ptrdiff_t, size_t -#include // for exception #include // for initializer_list #include // for is_signed, integral_constant #include // for exchange, forward @@ -97,10 +96,6 @@ constexpr T narrow_cast(U&& u) noexcept return static_cast(std::forward(u)); } -struct narrowing_error : public std::exception -{ -}; - namespace details { template @@ -120,9 +115,9 @@ constexpr T narrow(U u) noexcept(false) { T t = narrow_cast(u); - if (static_cast(t) != u) gsl::details::throw_exception(narrowing_error()); + if (static_cast(t) != u) gsl::details::terminate(); if (!details::is_same_signedness::value && ((t < T{}) != (u < U{}))) - gsl::details::throw_exception(narrowing_error()); + gsl::details::terminate(); return t; }