[string.view.synop]

# 27 Strings library [[strings]](./#strings)

## 27.3 String view classes [[string.view]](string.view#synop)

### 27.3.2 Header <string_view> synopsis [string.view.synop]

[ð](#header:%3cstring_view%3e)

// mostly freestanding#include <compare> // see [[compare.syn]](compare.syn "17.12.1 Header <compare> synopsis")namespace std {// [[string.view.template]](string.view.template "27.3.3 Class template basic_­string_­view"), class template basic_string_viewtemplate<class charT, class traits = char_traits<charT>>class basic_string_view; // partially freestandingtemplate<class charT, class traits>constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true; template<class charT, class traits>constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true; // [[string.view.comparison]](string.view.comparison "27.3.4 Non-member comparison functions"), non-member comparison functionstemplate<class charT, class traits>constexpr bool operator==(basic_string_view<charT, traits> x,
 type_identity_t<basic_string_view<charT, traits>> y) noexcept; template<class charT, class traits>constexpr *see below* operator<=>(basic_string_view<charT, traits> x,
 type_identity_t<basic_string_view<charT,
 traits>> y) noexcept; // [[string.view.io]](string.view.io "27.3.5 Inserters and extractors"), inserters and extractorstemplate<class charT, class traits> basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os,
 basic_string_view<charT, traits> str); // hosted// basic_string_view [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]")*s*using string_view = basic_string_view<char>; using u8string_view = basic_string_view<char8_t>; using u16string_view = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; using wstring_view = basic_string_view<wchar_t>; // [[string.view.hash]](string.view.hash "27.3.6 Hash support"), hash supporttemplate<class T> struct hash; template<> struct hash<string_view>; template<> struct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>; inline namespace literals {inline namespace string_view_literals {// [[string.view.literals]](string.view.literals "27.3.7 Suffix for basic_­string_­view literals"), suffix for basic_string_view literalsconstexpr string_view operator""sv(const char* str, size_t len) noexcept; constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept; }}}

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L591)

The function templates defined in [[utility.swap]](utility.swap "22.2.2 swap") and [[iterator.range]](iterator.range "24.7 Range access") are available when <string_view> is included[.](#1.sentence-1)
