Files
2025-10-25 03:02:53 +03:00

61 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[string.view.comparison]
# 27 Strings library [[strings]](./#strings)
## 27.3 String view classes [[string.view]](string.view#comparison)
### 27.3.4 Non-member comparison functions [string.view.comparison]
[🔗](#lib:operator==,basic_string_view)
`template<class charT, class traits>
constexpr bool operator==(basic_string_view<charT, traits> lhs,
type_identity_t<basic_string_view<charT, traits>> rhs) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1610)
*Returns*: lhs.compare(rhs) == 0[.](#1.sentence-1)
[🔗](#lib:operator%3c=%3e,basic_string_view)
`template<class charT, class traits>
constexpr see below operator<=>(basic_string_view<charT, traits> lhs,
type_identity_t<basic_string_view<charT, traits>> rhs) noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1623)
Let R denote the type traits::comparison_category if
that [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3Template argument deduction")),
otherwise R is weak_ordering[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1628)
*Mandates*: R denotes a comparison category type ([[cmp.categories]](cmp.categories "17.12.2Comparison category types"))[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1632)
*Returns*: static_cast<R>(lhs.compare(rhs) <=> 0)[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1636)
[*Note [1](#note-1)*:
The usage of type_identity_t as parameter
ensures that an object of type basic_string_view<charT, traits> can always be compared with an object of a type T with
an implicit conversion to basic_string_view<charT, traits>, and
vice versa, as per [[over.match.oper]](over.match.oper "12.2.2.3Operators in expressions")[.](#5.sentence-1)
— *end note*]