Update string_view.qbk

This commit is contained in:
Peter Dimov
2021-10-10 00:44:00 +03:00
parent 52c58efc36
commit 038064e824
2 changed files with 129 additions and 3 deletions

View File

@ -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<class A> basic_string_view(std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;
basic_string_view(std::basic_string_view<Ch, std::char_traits<Ch>> const& str ) noexcept;
template<class A> basic_string_view( std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;
basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch>> const& str ) noexcept;
// conversions
template<class A> operator std::basic_string<Ch, std::char_traits<Ch>, A>() const;
template<class Ch2> operator std::basic_string_view<Ch2>() 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<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str )
// typedef names
typedef basic_string_view<char> string_view;
typedef basic_string_view<wchar_t> wstring_view;
typedef basic_string_view<char16_t> u16string_view;
@ -176,6 +218,86 @@ typedef basic_string_view<char8_t> 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<class A> basic_string_view( std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;]
[endsect]
[section basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch>> 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]

View File

@ -1136,6 +1136,8 @@ public:
#endif
};
// stream inserter
template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str )
{
Ch const* p = str.data();
@ -1170,6 +1172,8 @@ template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& o
template<class Ch> BOOST_CONSTEXPR_OR_CONST std::size_t basic_string_view<Ch>::npos;
#endif
// typedef names
typedef basic_string_view<char> string_view;
typedef basic_string_view<wchar_t> wstring_view;