61 lines
2.2 KiB
Markdown
61 lines
2.2 KiB
Markdown
[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.3 Qualified names [expr.prim.id.qual]") is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template 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.2 Comparison 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.3 Operators in expressions")[.](#5.sentence-1)
|
||
|
||
â *end note*]
|