[libcxx-commits] [PATCH] D105040: [libc++] NFCI: Remove code duplication and obsolete declarations in wrap_iter
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 28 09:46:44 PDT 2021
Quuxplusone added a comment.
If buildkite is happy, I'm happy.
================
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;
}
----------------
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.
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