Кстати, я пробую это с G++ багажник.
Код: Выделить всё
#include
#include
#include
using namespace std::literals::string_view_literals;
int main(const int argv, const char *const argc[])
{
auto test = "a b c"sv | std::views::lazy_split("\\s+"sv) | std::ranges::to();
static_assert("a"sv == test[0]);
return 0;
}
Код: Выделить всё
: In function 'int main(int, const char* const*)':
:10:25: error: no match for 'operator==' (operand types are 'std::basic_string_view' and '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'})
10 | static_assert("a"sv == test[0]);
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/iterator:63,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/ranges:43,
from :1:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_iterator.h:527:5: note: candidate: 'template constexpr bool std::operator==(const reverse_iterator&, const reverse_iterator&) requires requires{{std::operator==::__x->base() == std::operator==::__y->base()} -> decltype(auto) [requires std::convertible_to];}' (reversed)
527 | operator==(const reverse_iterator& __x,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_iterator.h:527:5: note: template argument deduction/substitution failed:
:10:34: note: '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} is not derived from 'const std::reverse_iterator'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_iterator.h:1667:5: note: candidate: 'template constexpr bool std::operator==(const move_iterator&, const move_iterator&) requires requires{{std::operator==::__x->base() == std::operator==::__y->base()} -> decltype(auto) [requires std::convertible_to];}' (reversed)
1667 | operator==(const move_iterator& __x,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
:10:34: note: '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} is not derived from 'const std::move_iterator'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/string:43,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/locale_classes.h:40,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/ios_base.h:41,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/streambuf:43,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/streambuf_iterator.h:35,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/iterator:66:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/allocator.h:235:5: note: candidate: 'template constexpr bool std::operator==(const allocator&, const allocator&)' (reversed)
235 | operator==(const allocator&, const allocator&)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
:10:34: note: '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} is not derived from 'const std::allocator'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_algobase.h:64,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/string:51:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_pair.h:1010:5: note: candidate: 'template constexpr bool std::operator==(const pair&, const pair&)' (reversed)
1010 | operator==(const pair& __x, const pair& __y)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_pair.h:1010:5: note: template argument deduction/substitution failed:
:10:34: note: '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} is not derived from 'const std::pair'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/basic_string.h:47,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/string:54:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/string_view:609:5: note: candidate: 'template constexpr bool std::operator==(basic_string_view, type_identity_t)' (reversed)
609 | operator==(basic_string_view __x,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/string_view:609:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::ranges::lazy_split_view::_OuterIter::value_type' is not derived from 'std::basic_string_view'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/basic_string.h:3772:5: note: candidate: 'template constexpr bool std::operator==(const __cxx11::basic_string&, const _CharT*)' (reversed)
3772 | operator==(const basic_string& __lhs,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
:10:34: note: '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} is not derived from 'const std::__cxx11::basic_string'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/uses_allocator_args.h:39,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/memory_resource.h:41,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/string:67:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/tuple:2556:5: note: candidate: 'template constexpr bool std::operator==(const tuple&, const tuple&)' (reversed)
2556 | operator==(const tuple& __t,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/tuple:2556:5: note: template argument deduction/substitution failed:
:10:34: note: '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} is not derived from 'const std::tuple'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/ranges:44:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/optional:1292:5: note: candidate: 'template constexpr bool std::operator==(const optional&, nullopt_t)' (reversed)
1292 | operator==(const optional& __lhs, nullopt_t) noexcept
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/optional:1292:5: note: template argument deduction/substitution failed:
:10:34: note: '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} is not derived from 'const std::optional'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/ranges:3451:11: note: candidate: 'constexpr bool std::ranges::operator==(const lazy_split_view::_OuterIter&, std::default_sentinel_t)' (reversed)
3451 | operator==(const _OuterIter& __x, default_sentinel_t)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/ranges:3451:40: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} to 'const std::ranges::lazy_split_view::_OuterIter&'
3451 | operator==(const _OuterIter& __x, default_sentinel_t)
| ~~~~~~~~~~~~~~~~~~^~~
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/ios_base.h:46:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/system_error:465:3: note: candidate: 'bool std::operator==(const error_code&, const error_condition&)' (reversed)
465 | operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/system_error:465:32: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} to 'const std::error_code&'
465 | operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
| ~~~~~~~~~~~~~~~~~~^~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_iterator.h:586:5: note: candidate: 'template constexpr bool std::operator==(const reverse_iterator&, const reverse_iterator&) requires requires{{std::operator==::__x->base() == std::operator==::__y->base()} -> decltype(auto) [requires std::convertible_to];}'
586 | operator==(const reverse_iterator& __x,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_iterator.h:586:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::reverse_iterator'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_iterator.h:1737:5: note: candidate: 'template constexpr bool std::operator==(const move_iterator&, const move_iterator&)'
1737 | operator==(const move_iterator& __x,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::move_iterator'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/iosfwd:42,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stream_iterator.h:35,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/iterator:65:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/postypes.h:192:5: note: candidate: 'template bool std::operator==(const fpos&, const fpos&)'
192 | operator==(const fpos& __lhs, const fpos& __rhs)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::fpos'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/string_view:609:5: note: candidate: 'constexpr bool std::operator==(basic_string_view, type_identity_t) [with _CharT = char; _Traits = char_traits; type_identity_t = basic_string_view]'
609 | operator==(basic_string_view __x,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/string_view:610:68: note: no known conversion for argument 2 from '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} to 'std::type_identity_t' {aka 'std::basic_string_view'}
610 | type_identity_t __y)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/basic_string.h:3755:5: note: candidate: 'template constexpr bool std::operator==(const __cxx11::basic_string&, const __cxx11::basic_string&)'
3755 | operator==(const basic_string& __lhs,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::__cxx11::basic_string'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/streambuf_iterator.h:234:5: note: candidate: 'template bool std::operator==(const istreambuf_iterator&, const istreambuf_iterator&)'
234 | operator==(const istreambuf_iterator& __a,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/streambuf_iterator.h:234:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::istreambuf_iterator'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/optional:1232:5: note: candidate: 'template constexpr std::__optional_eq_t std::operator==(const optional&, const optional&)'
1232 | operator==(const optional& __lhs, const optional& __rhs)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/optional:1232:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::optional'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/optional:1360:5: note: candidate: 'template constexpr std::__optional_eq_t std::operator==(const optional&, const _Up&)'
1360 | operator==(const optional& __lhs, const _Up& __rhs)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/optional:1360:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::optional'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/optional:1366:5: note: candidate: 'template constexpr std::__optional_eq_t std::operator==(const _Up&, const optional&)'
1366 | operator==(const _Up& __lhs, const optional& __rhs)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/optional:1366:5: note: template argument deduction/substitution failed:
:10:34: note: '__gnu_cxx::__alloc_traits::value_type' {aka 'std::ranges::lazy_split_view::_OuterIter::value_type'} is not derived from 'const std::optional'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/span:43,
from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/ranges:45:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/array:303:5: note: candidate: 'template constexpr bool std::operator==(const array&, const array&)'
303 | operator==(const array& __one, const array& __two)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/array:303:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::array'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/ranges:49:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/variant:1266:3: note: candidate: 'template constexpr bool std::operator==(const variant&, const variant&)'
1266 | _VARIANT_RELATION_FUNCTION_TEMPLATE(==, equal)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/variant:1266:3: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::variant'
10 | static_assert("a"sv == test[0]);
| ^
In file included from /opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/vector:66,
from :3:
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_vector.h:2050:5: note: candidate: 'template constexpr bool std::operator==(const vector&, const vector&)'
2050 | operator==(const vector& __x, const vector& __y)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/bits/stl_vector.h:2050:5: note: template argument deduction/substitution failed:
:10:34: note: 'std::basic_string_view' is not derived from 'const std::vector'
10 | static_assert("a"sv == test[0]);
| ^
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/system_error:449:3: note: candidate: 'bool std::operator==(const error_code&, const error_code&)'
449 | operator==(const error_code& __lhs, const error_code& __rhs) noexcept
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/system_error:449:32: note: no known conversion for argument 1 from 'std::basic_string_view' to 'const std::error_code&'
449 | operator==(const error_code& __lhs, const error_code& __rhs) noexcept
| ~~~~~~~~~~~~~~~~~~^~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/system_error:480:3: note: candidate: 'bool std::operator==(const error_condition&, const error_condition&)'
480 | operator==(const error_condition& __lhs,
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/system_error:480:37: note: no known conversion for argument 1 from 'std::basic_string_view' to 'const std::error_condition&'
480 | operator==(const error_condition& __lhs,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/variant:1273:18: note: candidate: 'constexpr bool std::operator==(monostate, monostate)'
1273 | constexpr bool operator==(monostate, monostate) noexcept { return true; }
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/variant:1273:29: note: no known conversion for argument 1 from 'std::basic_string_view' to 'std::monostate'
1273 | constexpr bool operator==(monostate, monostate) noexcept { return true; }
| ^~~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/ranges:3443:11: note: candidate: 'constexpr bool std::ranges::operator==(const lazy_split_view::_OuterIter&, const lazy_split_view::_OuterIter&) requires forward_range'
3443 | operator==(const _OuterIter& __x, const _OuterIter& __y)
| ^~~~~~~~
/opt/compiler-explorer/gcc-trunk-20240503/include/c++/15.0.0/ranges:3443:40: note: no known conversion for argument 1 from 'std::basic_string_view' to 'const std::ranges::lazy_split_view::_OuterIter&'
3443 | operator==(const _OuterIter& __x, const _OuterIter& __y)
| ~~~~~~~~~~~~~~~~~~^~~
Compiler returned: 1
Подробнее здесь: https://stackoverflow.com/questions/784 ... estostdvec