[libcxx-commits] [PATCH] D105040: [libc++] NFCI: Remove code duplication and obsolete declarations in wrap_iter

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 29 07:50:55 PDT 2021


ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

Fixed and verified the modular build locally. We were missing an include of `__algorithm/move.h` in `inplace_merge.h`.



================
Comment at: libcxx/include/__iterator/wrap_iter.h:225-231
+template <class _Iter1>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT
 {
-#if _LIBCPP_DEBUG_LEVEL == 2
-    _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
-                   "Attempted to subtract incompatible iterators");
-#endif
-    return __x.base() - __y.base();
+    __x += __n;
+    return __x;
 }
----------------
Quuxplusone wrote:
> Could this `operator+` become a hidden friend of `__wrap_iter`?
> I'm not asking for all the relational operators to become hidden friends, because they're parameterized on //two// types, `_Iter1` and `_Iter2` (and I don't understand the ramifications/rationale of that). But for this `operator+`, the transformation to hidden friend should be pretty trivial.
I think I'd rather be consistent and have them all be non-member functions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105040/new/

https://reviews.llvm.org/D105040



More information about the libcxx-commits mailing list