Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strengthen exception specification for numeric operations #3887

Merged
merged 7 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions stl/inc/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -1333,21 +1333,24 @@ _GENERIC_MATH_SPECIAL_UINT1(sph_neumann)
#undef _GENERIC_MATH_SPECIAL_UINT1
#undef _GENERIC_MATH_SPECIAL_UINT2

_EXPORT_STD _NODISCARD inline double hypot(const double _Dx, const double _Dy, const double _Dz) {
_EXPORT_STD _NODISCARD inline double hypot(const double _Dx, const double _Dy, const double _Dz) noexcept
/* strengthened */ {
return __std_smf_hypot3(_Dx, _Dy, _Dz);
}

_EXPORT_STD _NODISCARD inline float hypot(const float _Dx, const float _Dy, const float _Dz) {
_EXPORT_STD _NODISCARD inline float hypot(const float _Dx, const float _Dy, const float _Dz) noexcept
/* strengthened */ {
return __std_smf_hypot3f(_Dx, _Dy, _Dz);
}

_EXPORT_STD _NODISCARD inline long double hypot(const long double _Dx, const long double _Dy, const long double _Dz) {
_EXPORT_STD _NODISCARD inline long double hypot(
const long double _Dx, const long double _Dy, const long double _Dz) noexcept /* strengthened */ {
return __std_smf_hypot3(static_cast<double>(_Dx), static_cast<double>(_Dy), static_cast<double>(_Dz));
}

_EXPORT_STD template <class _Ty1, class _Ty2, class _Ty3,
enable_if_t<is_arithmetic_v<_Ty1> && is_arithmetic_v<_Ty2> && is_arithmetic_v<_Ty3>, int> = 0>
_NODISCARD auto hypot(const _Ty1 _Dx, const _Ty2 _Dy, const _Ty3 _Dz) {
_NODISCARD auto hypot(const _Ty1 _Dx, const _Ty2 _Dy, const _Ty3 _Dz) noexcept /* strengthened */ {
// N4950 [cmath.syn]/3 "Sufficient additional overloads"
// Note that this template is selected by overload resolution only when at least one
// argument is double/long double/integral but not all three are double or long double.
Expand All @@ -1358,7 +1361,7 @@ _NODISCARD auto hypot(const _Ty1 _Dx, const _Ty2 _Dy, const _Ty3 _Dz) {

#if _HAS_CXX20
template <class _Ty>
_NODISCARD constexpr _Ty _Linear_for_lerp(const _Ty _ArgA, const _Ty _ArgB, const _Ty _ArgT) {
_NODISCARD constexpr _Ty _Linear_for_lerp(const _Ty _ArgA, const _Ty _ArgB, const _Ty _ArgT) noexcept {
if (_STD is_constant_evaluated()) {
auto _Smaller = _ArgT;
auto _Larger = _ArgB - _ArgA;
Expand Down
Loading