[libcxx-commits] [PATCH] D142521: [libc++][ranges][NFC] Move iterator classes out of `lazy_split_view` and `zip_view`.

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jan 26 20:10:18 PST 2023


var-const added a subscriber: huixie90.
var-const added a comment.

There is a GCC failure on the CI that exposed two interesting issues:

1. (Found by @huixie90) Moving iterator classes out of the view class can lead to a noticeable difference in behavior. What was previously template parameters of the view (but not the iterator) becomes template parameters of the iterator. This can add more namespaces and associated classes via ADL when doing overload resolution for the iterator. A Godbolt demo from @huixie90: https://godbolt.org/z/sEzjnnEeK

2. There is a divergence in behavior between GCC on one side and Clang and MSVC on the other side (https://godbolt.org/z/bbxv75aE7):

  template <class T>
  concept Foo = requires(T val) {
    val == val;
  };
  
  template <class T>
  struct Bar {};
  template <class T>
  bool operator==(const Bar<T>&, const Bar<T>&); // Overload 1
  
  template <class T>
  requires Foo<Bar<T>>
  bool operator==(const Bar<T>&, int); // Overload 2
  
  static_assert(Foo<Bar<int>>);

In this example, Clang and MSVC would not instantiate overload 2 of `operator==` when evaluating the `Foo` concept. GCC, on the other hand, instantiates overload 2 which leads to infinite recursion since overload 2 depends on `Foo`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142521



More information about the libcxx-commits mailing list