[all-commits] [llvm/llvm-project] d05ab1: [libc++] Remove redundant and somewhat confusing a...

Louis Dionne via All-commits all-commits at lists.llvm.org
Tue May 6 12:44:47 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d05ab119e188be99697f142a02c6b71137fde082
      https://github.com/llvm/llvm-project/commit/d05ab119e188be99697f142a02c6b71137fde082
  Author: Louis Dionne <ldionne.2 at gmail.com>
  Date:   2025-05-06 (Tue, 06 May 2025)

  Changed paths:
    M libcxx/include/__iterator/advance.h
    M libcxx/include/__iterator/next.h
    M libcxx/include/__iterator/prev.h
    M libcxx/test/libcxx/iterators/assert.next.pass.cpp
    M libcxx/test/libcxx/iterators/assert.prev.pass.cpp

  Log Message:
  -----------
  [libc++] Remove redundant and somewhat confusing assertions around advance() (#133276)

The std::advance function has a clear precondition that it can only be
called with a negative distance when a bidirectional iterator is used.
However, prev() and next() don't have such preconditions explicitly,
they inherit it from calling advance().

This patch removes assertions in prev() and next() that were duplicates
of similar ones in advance(), and removes a copy-pasted comment that was
trying to justify the use of _LIBCPP_ASSERT_PEDANTIC but IMO is creating
confusion with little benefit.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list