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:
- According to cppreference the above mentioned call should be a legitimate call or am I missing sth?
- If it is a legitimate call then is there any way to make the clang to accept the call like GCC?
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_beginis not satisfied on thestd::subrangecreated from the vector bystd::rotatedespitestd::subrangeobviously having a.begin()member. As a result,std::rotatecan't be called.