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 …