mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
deprecate gsl::details::throw_exception. remove unused header in gsl_assert. gsl_util to use terminate instead of throw_exception
This commit is contained in:
parent
6c5c708877
commit
17ad4495fb
@ -18,7 +18,6 @@
|
|||||||
#define GSL_CONTRACTS_H
|
#define GSL_CONTRACTS_H
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept> // for logic_error
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// make suppress attributes parse for some compilers
|
// make suppress attributes parse for some compilers
|
||||||
@ -111,8 +110,8 @@ namespace details
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename Exception>
|
template <typename Exception>
|
||||||
|
[[deprecated("GSL no longer supports throwing for contract violations. Use gsl::details::terminate() instead.")]]
|
||||||
[[noreturn]] void throw_exception(Exception&&) noexcept
|
[[noreturn]] void throw_exception(Exception&&) noexcept
|
||||||
{
|
{
|
||||||
gsl::details::terminate();
|
gsl::details::terminate();
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef> // for ptrdiff_t, size_t
|
#include <cstddef> // for ptrdiff_t, size_t
|
||||||
#include <exception> // for exception
|
|
||||||
#include <initializer_list> // for initializer_list
|
#include <initializer_list> // for initializer_list
|
||||||
#include <type_traits> // for is_signed, integral_constant
|
#include <type_traits> // for is_signed, integral_constant
|
||||||
#include <utility> // for exchange, forward
|
#include <utility> // for exchange, forward
|
||||||
@ -97,10 +96,6 @@ constexpr T narrow_cast(U&& u) noexcept
|
|||||||
return static_cast<T>(std::forward<U>(u));
|
return static_cast<T>(std::forward<U>(u));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct narrowing_error : public std::exception
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace details
|
namespace details
|
||||||
{
|
{
|
||||||
template <class T, class U>
|
template <class T, class U>
|
||||||
@ -120,9 +115,9 @@ constexpr
|
|||||||
T narrow(U u) noexcept(false)
|
T narrow(U u) noexcept(false)
|
||||||
{
|
{
|
||||||
T t = narrow_cast<T>(u);
|
T t = narrow_cast<T>(u);
|
||||||
if (static_cast<U>(t) != u) gsl::details::throw_exception(narrowing_error());
|
if (static_cast<U>(t) != u) gsl::details::terminate();
|
||||||
if (!details::is_same_signedness<T, U>::value && ((t < T{}) != (u < U{})))
|
if (!details::is_same_signedness<T, U>::value && ((t < T{}) != (u < U{})))
|
||||||
gsl::details::throw_exception(narrowing_error());
|
gsl::details::terminate();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user