[all-commits] [llvm/llvm-project] 12b01a: [libc++] Don't trigger unsigned conversion warning...

Louis Dionne via All-commits all-commits at lists.llvm.org
Tue Jun 16 10:48:12 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 12b01ab7fa10939d67ac7cb2da1d3ca8a41b5fcd
      https://github.com/llvm/llvm-project/commit/12b01ab7fa10939d67ac7cb2da1d3ca8a41b5fcd
  Author: Louis Dionne <ldionne at apple.com>
  Date:   2020-06-16 (Tue, 16 Jun 2020)

  Changed paths:
    M libcxx/include/iterator
    M libcxx/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp

  Log Message:
  -----------
  [libc++] Don't trigger unsigned conversion warnings in std::advance

The Standard documents the signature of std::advance as

    template <class Iter, class Distance>
    constexpr void advance(Iter& i, Distance n);

Furthermore, it does not appear to put any restriction on what the type
of Distance should be. While it is understood that it should usually
be std::iterator_traits::difference_type, I couldn't find any wording
that mandates that. Similarly, I couldn't find wording that forces the
distance to be a signed type.

This patch changes std::advance to accept any type in the second argument,
which appears to be what the Standard mandates. We then coerce it to the
iterator's difference type, but that's an implementation detail.

Differential Revision: https://reviews.llvm.org/D81425




More information about the All-commits mailing list