From 038064e8241fa1fe97ebfd4cbd8f03736f35304d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 10 Oct 2021 00:44:00 +0300 Subject: [PATCH] Update string_view.qbk --- doc/string_view.qbk | 128 ++++++++++++++++++++++++++++- include/boost/core/string_view.hpp | 4 + 2 files changed, 129 insertions(+), 3 deletions(-) diff --git a/doc/string_view.qbk b/doc/string_view.qbk index 128c906..51c1e0b 100644 --- a/doc/string_view.qbk +++ b/doc/string_view.qbk @@ -68,8 +68,13 @@ public: constexpr basic_string_view( Ch const* str ) noexcept; constexpr basic_string_view( Ch const* str, size_type len ) noexcept; constexpr basic_string_view( Ch const* begin, Ch const* end ) noexcept; - template basic_string_view(std::basic_string, A> const& str ) noexcept; - basic_string_view(std::basic_string_view> const& str ) noexcept; + template basic_string_view( std::basic_string, A> const& str ) noexcept; + basic_string_view( std::basic_string_view> const& str ) noexcept; + + // conversions + + template operator std::basic_string, A>() const; + template operator std::basic_string_view() const noexcept; // iterator support @@ -108,6 +113,8 @@ public: constexpr size_type copy( Ch* s, size_type n, size_type pos = 0 ) const; constexpr basic_string_view substr( size_type pos = 0, size_type n = npos ) const; + // compare + constexpr int compare( basic_string_view s ) const noexcept; constexpr int compare( size_type pos1, size_type n1, basic_string_view s ) const; constexpr int compare( size_type pos1, size_type n1, basic_string_view s, size_type pos2, size_type n2 ) const; @@ -115,47 +122,82 @@ public: constexpr int compare( size_type pos1, size_type n1, Ch const* s ) const; constexpr int compare( size_type pos1, size_type n1, Ch const* s, size_type n2 ) const; + // starts_with + constexpr bool starts_with( basic_string_view x ) const noexcept; constexpr bool starts_with( Ch x ) const noexcept; constexpr bool starts_with( Ch const* x ) const; + // ends_with + constexpr bool ends_with( basic_string_view x ) const noexcept; constexpr bool ends_with( Ch x ) const noexcept; constexpr bool ends_with( Ch const* x ) const; - // searching + // find constexpr size_type find( basic_string_view s, size_type pos = 0 ) const noexcept; constexpr size_type find( Ch c, size_type pos = 0 ) const noexcept; constexpr size_type find( Ch const* s, size_type pos, size_type n ) const; constexpr size_type find( Ch const* s, size_type pos = 0 ) const; + // rfind + constexpr size_type rfind( basic_string_view s, size_type pos = npos ) const noexcept; constexpr size_type rfind( Ch c, size_type pos = npos ) const noexcept; constexpr size_type rfind( Ch const* s, size_type pos, size_type n ) const; constexpr size_type rfind( Ch const* s, size_type pos = npos ) const; + // find_first_of + constexpr size_type find_first_of( basic_string_view s, size_type pos = 0 ) const noexcept; constexpr size_type find_first_of( Ch c, size_type pos = 0 ) const noexcept; constexpr size_type find_first_of( Ch const* s, size_type pos, size_type n ) const; constexpr size_type find_first_of( Ch const* s, size_type pos = 0 ) const; + // find_last_of + constexpr size_type find_last_of( basic_string_view s, size_type pos = npos ) const noexcept; constexpr size_type find_last_of( Ch c, size_type pos = npos ) const noexcept; constexpr size_type find_last_of( Ch const* s, size_type pos, size_type n ) const; constexpr size_type find_last_of( Ch const* s, size_type pos = npos ) const; + // find_first_not_of + constexpr size_type find_first_not_of( basic_string_view s, size_type pos = 0 ) const noexcept; constexpr size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept; constexpr size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const; constexpr size_type find_first_not_of( Ch const* s, size_type pos = 0 ) const; + // find_last_not_of + constexpr size_type find_last_not_of( basic_string_view s, size_type pos = npos ) const noexcept; constexpr size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept; constexpr size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const; constexpr size_type find_last_not_of( Ch const* s, size_type pos = npos ) const; + + // contains + + constexpr bool contains( basic_string_view sv ) const noexcept; + constexpr bool contains( Ch c ) const noexcept; + constexpr bool contains( Ch const* s ) const noexcept; + + // relational operators + + constexpr friend bool operator==( basic_string_view sv1, basic_string_view sv2 ) noexcept; + constexpr friend bool operator!=( basic_string_view sv1, basic_string_view sv2 ) noexcept; + constexpr friend bool operator<( basic_string_view sv1, basic_string_view sv2 ) noexcept; + constexpr friend bool operator<=( basic_string_view sv1, basic_string_view sv2 ) noexcept; + constexpr friend bool operator>( basic_string_view sv1, basic_string_view sv2 ) noexcept; + constexpr friend bool operator>=( basic_string_view sv1, basic_string_view sv2 ) noexcept; }; +// stream inserter + +template std::basic_ostream& operator<<( std::basic_ostream& os, basic_string_view str ) + +// typedef names + typedef basic_string_view string_view; typedef basic_string_view wstring_view; typedef basic_string_view u16string_view; @@ -176,6 +218,86 @@ typedef basic_string_view u8string_view; [endsect] +[section constexpr basic_string_view( Ch const* str ) noexcept;] +[endsect] + +[section constexpr basic_string_view( Ch const* str, size_type len ) noexcept;] +[endsect] + +[section constexpr basic_string_view( Ch const* begin, Ch const* end ) noexcept;] +[endsect] + +[section template basic_string_view( std::basic_string, A> const& str ) noexcept;] +[endsect] + +[section basic_string_view( std::basic_string_view> const& str ) noexcept;] +[endsect] + +[endsect] + +[section Conversions] +[endsect] + +[section Iterator Support] +[endsect] + +[section Capacity] +[endsect] + +[section Element Access] +[endsect] + +[section Modifiers] +[endsect] + +[section String Operations] + +[section copy] +[endsect] + +[section substr] +[endsect] + +[section compare] +[endsect] + +[section starts_with] +[endsect] + +[section ends_with] +[endsect] + +[endsect] + +[section Searching] + +[section find] +[endsect] + +[section rfind] +[endsect] + +[section find_first_of] +[endsect] + +[section find_last_of] +[endsect] + +[section find_first_not_of] +[endsect] + +[section find_last_not_of] +[endsect] + +[section contains] +[endsect] + +[endsect] + +[section Relational Operators] +[endsect] + +[section Stream Inserter] [endsect] [endsect] diff --git a/include/boost/core/string_view.hpp b/include/boost/core/string_view.hpp index d7fd3b2..d74a6f2 100644 --- a/include/boost/core/string_view.hpp +++ b/include/boost/core/string_view.hpp @@ -1136,6 +1136,8 @@ public: #endif }; +// stream inserter + template std::basic_ostream& operator<<( std::basic_ostream& os, basic_string_view str ) { Ch const* p = str.data(); @@ -1170,6 +1172,8 @@ template std::basic_ostream& operator<<( std::basic_ostream& o template BOOST_CONSTEXPR_OR_CONST std::size_t basic_string_view::npos; #endif +// typedef names + typedef basic_string_view string_view; typedef basic_string_view wstring_view;