From 9563f3b571d1dc1f40a546a86c11904b1748ff86 Mon Sep 17 00:00:00 2001 From: Christopher Di Bella Date: Mon, 26 Jul 2021 21:00:40 +0000 Subject: [PATCH] [libcxx][NFC] adjusts 41b17c44 so it meets requested feedback Feedback requested in D106735 applied in Diff 3 seem to have reverted in Diff 4. This patch fixes that up. Differential Revision: https://reviews.llvm.org/D106829 --- libcxx/include/__iterator/advance.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__iterator/advance.h b/libcxx/include/__iterator/advance.h index 674a304..47bce1d 100644 --- a/libcxx/include/__iterator/advance.h +++ b/libcxx/include/__iterator/advance.h @@ -76,7 +76,7 @@ struct __advance_fn final : private __function_like { private: template _LIBCPP_HIDE_FROM_ABI - static constexpr _Tp __magnitude_geq(_Tp __a, _Tp __b) { + static constexpr _Tp __magnitude_geq(_Tp __a, _Tp __b) noexcept { return __a < 0 ? (__a <= __b) : (__a >= __b); } @@ -153,12 +153,12 @@ public: template _Sp> _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound) const { - _LIBCPP_ASSERT((bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) || (__n >= 0), + _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>), "If `n < 0`, then `bidirectional_iterator && same_as` must be true."); // If `S` and `I` model `sized_sentinel_for`: if constexpr (sized_sentinel_for<_Sp, _Ip>) { // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`. - if (auto __M = __bound - __i; __magnitude_geq(__n, __M)) { + if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) { (*this)(__i, __bound); return __n - __M; } -- 2.7.4