[libcxx][NFC] adjusts 41b17c44 so it meets requested feedback
authorChristopher Di Bella <cjdb@google.com>
Mon, 26 Jul 2021 21:00:40 +0000 (21:00 +0000)
committerChristopher Di Bella <cjdb@google.com>
Tue, 27 Jul 2021 01:11:04 +0000 (01:11 +0000)
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

index 674a304..47bce1d 100644 (file)
@@ -76,7 +76,7 @@ struct __advance_fn final : private __function_like {
 private:
   template <class _Tp>
   _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 <input_or_output_iterator _Ip, sentinel_for<_Ip> _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<I> && same_as<I, S>` must be true.");
     // If `S` and `I` model `sized_sentinel_for<S, I>`:
     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;
       }