I have the following function that does a rotation to a vector of char :
void rotate()
{
std::ranges::rotate(_right, _right.begin() + 1);
}
_right is defined as :
std::vector<char> _right;
trying to compile it with clang 15, it complains that (https://godbolt.org/z/7ovTfxe31):
no matching function for call to '__begin'
the reason for that seems to be the following :
in instantiation of template type alias 'iterator_t' requested here
requires contiguous_iterator<iterator_t<_Derived>>
but I assume that vector is a contiguous container. Code compiles and run with GCC.
Here are my questions:
clang 15 and older compilers have issues with compiling libstdc++ algorithms due to how constraints are checked for satisfaction.
See LLVM Issue 44178: [concepts] deferred substitution into requirements of class template members not implemented. This is a known bug and has been resolved in clang 16.
Unlike GCC, clang doesn't defer instantiation of member constraints until member instantiation.
In libstdc++'s __begin
, the constraint __member_begin
is not satisfied on the std::subrange
created from the vector by std::rotate
despite std::subrange
obviously having a .begin()
member. As a result, std::rotate
can't be called.