【问题标题】:Ranges algorithm in LLVM 14 libc++LLVM 14 libc++ 中的范围算法
【发布时间】:2022-06-14 18:16:15
【问题描述】:

我有这个sn-p。

#include <algorithm>
#include <vector>

int main() {
    std::vector<int> v1 = {1, 2, 3};
    std::vector<int> v2 = {4, 5, 6};

    return std::ranges::equal(v1, v2);
}

我用 GCC 10 (Debian stable) 编译它,一切都很好:

$ g++ -std=c++20 test.cpp -o test
<compiles fine>

我用 Clang 14 和 libc++14(Debian 稳定版,从 apt.llvm.org 的包安装)编译它:

$ clang++-14 -std=c++20 -stdlib=libc++ test.cpp -o test
test.cpp:8:25: error: no member named \'equal\' in namespace \'std::ranges\'
    return std::ranges::equal(v1, v2);
           ~~~~~~~~~~~~~^
1 error generated.

很多其他事情也是如此。 libc++ 对范围库的支持真的那么落后还是我遗漏了什么?

    标签: c++ llvm c++20 libc++


    【解决方案1】:

    您可以在此处找到关于实现功能支持的详尽表格:https://en.cppreference.com/w/cpp/compiler_support

    对于 C++20 年代的“The One Ranges Proposal”,其中std::equal 是表格的一部分,表示“13(部分)”。

    这里还有另一个关于 clang 的概述:https://clang.llvm.org/cxx_status.html#cxx20。虽然它只列出了语言功能。

    【讨论】:

    • 我看到了“部分”,但我希望它不是那么部分:) 无论如何谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 2014-11-02
    • 1970-01-01
    相关资源
    最近更新 更多