# operator==,!=,<,<=,>,>=(std::basic_string_view)

C++
 Language Standard Library Headers Freestanding and hosted implementations Named requirements Language support library Concepts library (C++20) Diagnostics library Utilities library Strings library Containers library Iterators library Ranges library (C++20) Algorithms library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Filesystem library (C++17) Technical Specifications

Strings library
 Null-terminated strings Byte strings Multibyte strings Wide strings Classes basic_string basic_string_view(C++17) char_traits

 Defined in header  template< class CharT, class Traits > constexpr bool operator==( basic_string_view lhs,                            basic_string_view rhs ) noexcept; (1) (since C++17) template< class CharT, class Traits > constexpr bool operator!=( basic_string_view lhs,                            basic_string_view rhs ) noexcept; (2) (since C++17) template< class CharT, class Traits > constexpr bool operator<( basic_string_view lhs,                           basic_string_view rhs ) noexcept; (3) (since C++17) template< class CharT, class Traits > constexpr bool operator<=( basic_string_view lhs,                            basic_string_view rhs ) noexcept; (4) (since C++17) template< class CharT, class Traits > constexpr bool operator>( basic_string_view lhs,                           basic_string_view rhs ) noexcept; (5) (since C++17) template< class CharT, class Traits > constexpr bool operator>=( basic_string_view lhs,                            basic_string_view rhs ) noexcept; (6) (since C++17)

Compares two views.

All comparisons are done via the compare() member function (which itself is defined in terms of Traits::compare()):

• Two views are equal if both the size of lhs and rhs are equal and each character in lhs has an equivalent character in rhs at the same position.
• The ordering comparisons are done lexicographically -- the comparison is performed by a function equivalent to std::lexicographical_compare.

The implementation shall provide sufficient additional constexpr and noexcept overloads of these functions so that a basic_string_view<CharT,Traits> object sv may be compared to another object t with an implicit conversion to basic_string_view<CharT,Traits>, with semantics identical to comparing sv and basic_string_view<CharT,Traits>(t).

### Parameters

 lhs, rhs - views to compare

### Return value

true if the corresponding comparison holds, false otherwise.

### Complexity

Linear in the size of the views.
{"ft_lang_label":"__label__en","ft_lang_prob":0.5241347,"math_prob":0.61036384,"size":1776,"snap":"2019-35-2019-39","text_gpt3_token_len":449,"char_repetition_ratio":0.18002257,"word_repetition_ratio":0.14529915,"special_character_ratio":0.25675675,"punctuation_ratio":0.15438597,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9636494,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-20T00:16:28Z\",\"WARC-Record-ID\":\"<urn:uuid:98e4619d-91b5-4255-a98d-1b2464942705>\",\"Content-Length\":\"44741\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:cc8153d6-8f3a-456f-9272-ee8aa37dcded>\",\"WARC-Concurrent-To\":\"<urn:uuid:001895cf-03ff-438c-b947-22570d219bc1>\",\"WARC-IP-Address\":\"74.114.90.46\",\"WARC-Target-URI\":\"https://en.cppreference.com/w/cpp/string/basic_string_view/operator_cmp\",\"WARC-Payload-Digest\":\"sha1:WWERKTIMYLKUU6ISBVG2N6BLIIV4X6HQ\",\"WARC-Block-Digest\":\"sha1:DW7P4D2ZINYB6YLSCX6ZSB4YVEQLTCLE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514573759.32_warc_CC-MAIN-20190919224954-20190920010954-00147.warc.gz\"}"}