Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

Or am I missing something exceedingly obvious?

Godbolt

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#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

>Solution :

This seems to be a Clang bug, see this issue for explanation how it affects ranges when using libstdc++ and this issue with the underlying cause which is still open. 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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading