相关疑难解决方法(0)

为什么 clang 认为 gcc 的子范围不满足 gcc 的 __ranges_begin 函数概念要求?

clang 失败的代码(而 gcc 似乎很好)

    int arr[] { 111, 222, 333};
    ranges::subrange(
        ranges::begin(arr),ranges::end(arr) );
Run Code Online (Sandbox Code Playgroud)

看起来clang声称gcc的子范围没有开始功能?!

/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/iterator_concepts.h:953:35: note: and 'std::ranges::subrange<int *, int *, std::ranges::subrange_kind::sized> &' does not satisfy '__member_begin'

      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>

                                  ^

/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/iterator_concepts.h:937:33: note: because '__detail::__decay_copy(__t.begin())' would be invalid: no member named 'begin' in 'std::ranges::subrange<int *, int *, std::ranges::subrange_kind::sized>'

          { __detail::__decay_copy(__t.begin()) } -> input_or_output_iterator;

                                       ^

/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/iterator_concepts.h:953:59: note: and 'std::ranges::subrange<int *, int *, std::ranges::subrange_kind::sized> &' does not satisfy '__adl_begin'

      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
Run Code Online (Sandbox Code Playgroud)

[直播]


gcc …

c++ clang c++-concepts range-v3 c++20

5
推荐指数
0
解决办法
133
查看次数

标签 统计

c++ ×1

c++-concepts ×1

c++20 ×1

clang ×1

range-v3 ×1