23 Strings library [strings]

23.3 String view classes [string.view]

23.3.4 Non-member comparison functions [string.view.comparison]

Let S be basic_string_view<charT, traits>, and sv be an instance of S.
Implementations shall provide sufficient additional overloads marked constexpr and noexcept so that an object t with an implicit conversion to S can be compared according to Table 81.
Table 81: Additional basic_string_view comparison overloads [tab:string.view.comparison.overloads]
Expression
Equivalent to
t == sv
S(t) == sv
sv == t
sv == S(t)
t != sv
S(t) != sv
sv != t
sv != S(t)
t < sv
S(t) < sv
sv < t
sv < S(t)
t > sv
S(t) > sv
sv > t
sv > S(t)
t <= sv
S(t) <= sv
sv <= t
sv <= S(t)
t >= sv
S(t) >= sv
sv >= t
sv >= S(t)
t <=> sv
S(t) <=> sv
sv <=> t
sv <=> S(t)
[Example 1: 
A sample conforming implementation for operator== would be: template<class charT, class traits> constexpr bool operator==(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs) noexcept { return lhs.compare(rhs) == 0; } template<class charT, class traits> constexpr bool operator==(basic_string_view<charT, traits> lhs, type_identity_t<basic_string_view<charT, traits>> rhs) noexcept { return lhs.compare(rhs) == 0; }
— end example]
template<class charT, class traits> constexpr bool operator==(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs) noexcept;
Returns: lhs.compare(rhs) == 0.
template<class charT, class traits> constexpr see below operator<=>(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs) noexcept;
Let R denote the type traits​::​comparison_category if that qualified-id is valid and denotes a type ([temp.deduct]), otherwise R is weak_ordering.
Mandates: R denotes a comparison category type ([cmp.categories]).
Returns: static_cast<R>(lhs.compare(rhs) <=> 0).