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

Bogdan Graur via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 10 02:33:31 PDT 2021


bgraur added a comment.

Hi Louis,

This patch introduces an error when std::rel_ops are used.
Here's a small reproducer:

  #include <utility> // for std::rel_ops.
  #include <vector>
  
  using namespace std::rel_ops;
  
  struct T;
  void fn() {
    std::vector<T>::const_iterator a;
    for (std::vector<T>::const_iterator i; i >= a;)
      ;
  }

The compilation result:

  repro.cc:9:44: error: use of overloaded operator '>=' is ambiguous (with operand types 'std::vector<T>::const_iterator' (aka '__wrap_iter<const T *>') and 'std::vector<T>::const_iterator' (aka '__wrap_iter<const T *>'))
    for (std::vector<T>::const_iterator i; i >= a;)
                                           ~ ^  ~
  /google/src/cloud/bgraur/cherrypick/google3/third_party/crosstool/v18/llvm_unstable/toolchain/bin/../include/c++/v1/__utility/rel_ops.h:56:1: note: candidate function [with _Tp = std::__wrap_iter<const T *>]
  operator>=(const _Tp& __x, const _Tp& __y)
  ^
  /google/src/cloud/bgraur/cherrypick/google3/third_party/crosstool/v18/llvm_unstable/toolchain/bin/../include/c++/v1/__iterator/wrap_iter.h:201:6: note: candidate function [with _Iter1 = const T *, _Iter2 = const T *]
  bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
       ^
  1 error generated.

Could you please take a look?


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