The main purpose of this question is to draw community's attention to libstdc++ ranges not working with clang: https://bugs.llvm.org/show_bug.cgi?id=46746
Avi Kivity suggested this is a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97120
But then he also suggested this is a clang bug: https://bugs.llvm.org/show_bug.cgi?id=47509
Rafael Ávila de Espíndola boiled down the problem to the following code, which compiles with gcc, but not with clang:
template <typename _Tp>
concept __member_begin = requires(_Tp __t) {
{__t.begin()};
};
template <typename _Tp>
concept nothing = requires(_Tp __t) {
{42};
};
template <typename _Tp>
requires __member_begin<_Tp> void __ranges_begin() {}
template <typename _Derived>
struct view_interface {
void foo() requires __member_begin<_Derived> {}
void bar() requires nothing<decltype(__ranges_begin<_Derived>())> {}
};
struct drop_view : public view_interface<drop_view> {};
clang complains (https://godbolt.org/z/4c45oKMKK):
<source>:14:42: error: no matching function for call to '__ranges_begin'
void bar() requires nothing<decltype(__ranges_begin<_Derived>())> {}
^~~~~~~~~~~~~~~~~~~~~~~~
So the question is, who is right? Should this code compile or not?
And the more interesting question: can we please have working ranges with clang?