std::ranges::remove still not suported / broken on clang trunk when using libstdc++?

Viewed 203

Works fine on gcc trunk, but not on clang trunk, both with libstd++.

Or am I missing something exceedingly obvious?

Godbolt

#include <algorithm>
#include <iostream>
#include <ostream>
#include <vector>


std::ostream& operator<<(std::ostream& os, const std::vector<int>& v) {
    for (auto&& e: v) os << e << " "; 
    return os;
}

int main() {
    auto ints = std::vector<int>{1,2,3,4,5};
    std::cout << ints << "\n";
    auto [first, last] = std::ranges::remove(ints, 3);
    ints.erase(first, last);
    std::cout << ints << "\n";
}

gcc is clean. clang gives a WALL OF ERRORS, complaining about missing "__begin".

UPDATE: If I use -stdlib=libc++ then clang says "never heard of it", so I guess they are just not there yet.

new Godbolt

1 Answers

This seems to be a Clang bug, affecting ranges when using libstdc++, see this issue with the underlying cause which is still open and other issues linked to it as duplicates with examples how it affects ranges with libstdc++. There seems to have been some work on it about two weeks ago.

In libc++ std::ranges::remove does not seem to be implemented yet as you noticed and as stated on its status page for ranges implementation.

Related