VCCC  2024.05
VisualCamp Common C++ library
basic_string_view< CharT, Traits > Class Template Reference

#include </home/jarvis/actions-runner/jarvis-vccc-2/_work/vccc/vccc/include/vccc/string_view.hpp>

Detailed Description

template<typename CharT, typename Traits = std::char_traits<CharT>>
class vccc::basic_string_view< CharT, Traits >

The class template basic_string_view describes an object that can refer to a constant contiguous sequence of CharT with the first element of the sequence at position zero. Every specialization of vccc::basic_string_view is a TriviallyCopyable type.

Template Parameters
CharTcharacter type
TraitsCharTraits class specifying the operations on the character type. Like for std::basic_string, Traits::char_type must name the same type as CharT or the program is ill-formed.

Public Types

using traits_type = Traits
 
using value_type = CharT
 
using pointer = CharT *
 
using const_pointer = const CharT *
 
using reference = CharT &
 
using const_reference = const CharT &
 
using const_iterator = const_pointer
 
using iterator = const_iterator
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using reverse_iterator = const_reverse_iterator
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 

Public Member Functions

(constructor)

constructs a basic_string_view

constexpr basic_string_view () noexcept
 
constexpr basic_string_view (const basic_string_view &other) noexcept=default
 
constexpr basic_string_view (const CharT *s, size_type count)
 
constexpr basic_string_view (const CharT *s)
 
template<typename It , typename End , std::enable_if_t< detail::string_view_iter_ctor< It, End, CharT, size_type >::value, int > = 0>
constexpr basic_string_view (It first, End last)
 
template<typename R , std::enable_if_t< detail::string_view_range_ctor< R, basic_string_view >::value, int > = 0>
constexpr basic_string_view (R &&r)
 
constexpr basic_string_view (const std::basic_string< CharT, Traits > &s)
 
constexpr basic_string_view (std::basic_string< CharT, Traits > &&s)
 
 operator std::basic_string< CharT, Traits > () const
 
constexpr basic_string_view (std::nullptr_t)=delete
 
(operator=)

assigns a view

constexpr basic_string_viewoperator= (const basic_string_view &other) noexcept=default
 
begin/cbegin

returns an iterator to the beginning

constexpr const_iterator begin () const noexcept
 
constexpr const_iterator cbegin () const noexcept
 
end/cend

returns an iterator to the end

constexpr const_iterator end () const noexcept
 
constexpr const_iterator cend () const noexcept
 
rbegin/crbegin

returns a reverse iterator to the beginning

constexpr const_reverse_iterator rbegin () const noexcept
 
constexpr const_reverse_iterator crbegin () const noexcept
 
rend

returns a reverse iterator to the end

constexpr const_reverse_iterator rend () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
operator[]

accesses the specified character

constexpr const_reference operator[] (size_type pos) const
 
at

accesses the specified character with bounds checking

constexpr const_reference at (size_type pos) const
 
front

accesses the first character

constexpr const_reference front () const
 
back

accesses the last character

constexpr const_reference back () const
 
data

returns a pointer to the first character of a view

constexpr const_pointer data () const noexcept
 
size/length

returns the number of characters

constexpr size_type size () const noexcept
 
constexpr size_type length () const noexcept
 
max_size

returns the maximum number of characters

constexpr size_type max_size () const noexcept
 
empty

checks whether the view is empty

constexpr bool empty () const noexcept
 
remove_prefix

shrinks the view by moving its start forward

constexpr void remove_prefix (size_type n)
 
remove_suffix

shrinks the view by moving its end backward

constexpr void remove_suffix (size_type n)
 
swap

swaps the contents

constexpr void swap (basic_string_view &other) noexcept
 
copy

copies characters

constexpr size_type copy (value_type *dest, size_type count, size_type pos=0) const
 
substr

returns a substring

constexpr basic_string_view substr (size_type pos=0, size_type count=npos) const
 
compare

compares two views

constexpr int compare (basic_string_view other) const noexcept
 
constexpr int compare (size_type pos1, size_type count1, basic_string_view other) const
 
constexpr int compare (size_type pos1, size_type count1, basic_string_view other, size_type pos2, size_type count2) const
 
constexpr int compare (const CharT *s) const
 
constexpr int compare (size_type pos1, size_type count1, const value_type *s) const
 
constexpr int compare (size_type pos1, size_type count1, const value_type *s, size_type count2) const
 
starts_with

checks if the string view starts with the given prefix

constexpr bool starts_with (basic_string_view prefix) const noexcept
 
constexpr bool starts_with (value_type c) const noexcept
 
constexpr bool starts_with (const value_type *s) const
 
ends_with

checks if the string view ends with the given suffix

constexpr bool ends_with (basic_string_view sv) const noexcept
 
constexpr bool ends_with (value_type c) const noexcept
 
constexpr bool ends_with (const value_type *s) const
 
contains

checks if the string view contains the given substring or character

constexpr bool contains (basic_string_view sv) const noexcept
 
constexpr bool contains (value_type c) const noexcept
 
constexpr bool contains (const value_type *str) const
 
find

find characters in the view

constexpr size_type find (basic_string_view sv, size_type pos=0) const noexcept
 
constexpr size_type find (value_type c, size_type pos=0) const noexcept
 
constexpr size_type find (const value_type *str, size_type pos, size_type count) const
 
constexpr size_type find (const value_type *str, size_type pos=0) const
 
rfind

find the last occurrence of a substring

constexpr size_type rfind (basic_string_view sv, size_type pos=npos) const noexcept
 
constexpr size_type rfind (value_type c, size_type pos=npos) const noexcept
 
constexpr size_type rfind (const value_type *str, size_type pos, size_type count) const
 
constexpr size_type rfind (const value_type *str, size_type pos=npos) const
 
find_first_of

find first occurrence of characters

constexpr size_type find_first_of (basic_string_view sv, size_type pos=0) const noexcept
 
constexpr size_type find_first_of (value_type c, size_type pos=0) const noexcept
 
constexpr size_type find_first_of (const value_type *s, size_type pos, size_type count) const
 
constexpr size_type find_first_of (const value_type *s, size_type pos=0) const
 
find_last_of

find last occurrence of characters

constexpr size_type find_last_of (basic_string_view sv, size_type pos=npos) const noexcept
 
constexpr size_type find_last_of (value_type c, size_type pos=npos) const noexcept
 
constexpr size_type find_last_of (const value_type *s, size_type pos, size_type count) const
 
constexpr size_type find_last_of (const value_type *s, size_type pos=npos) const
 
find_first_not_of

find first absence of characters

constexpr size_type find_first_not_of (basic_string_view sv, size_type pos=0) const noexcept
 
constexpr size_type find_first_not_of (value_type c, size_type pos=0) const noexcept
 
constexpr size_type find_first_not_of (const value_type *s, size_type pos, size_type count) const
 
constexpr size_type find_first_not_of (const value_type *s, size_type pos=0) const
 
find_last_not_of

find last absence of characters

constexpr size_type find_last_not_of (basic_string_view sv, size_type pos=npos) const noexcept
 
constexpr size_type find_last_not_of (value_type c, size_type pos=npos) const noexcept
 
constexpr size_type find_last_not_of (const value_type *s, size_type pos, size_type count) const
 
constexpr size_type find_last_not_of (const value_type *s, size_type pos=npos) const
 

Static Public Attributes

static constexpr size_type npos = size_type(-1)
 

Member Typedef Documentation

◆ const_iterator

◆ const_pointer

using const_pointer = const CharT*

◆ const_reference

using const_reference = const CharT&

◆ const_reverse_iterator

using const_reverse_iterator = std::reverse_iterator<const_iterator>

◆ difference_type

using difference_type = std::ptrdiff_t

◆ iterator

◆ pointer

using pointer = CharT*

◆ reference

using reference = CharT&

◆ reverse_iterator

◆ size_type

using size_type = std::size_t

◆ traits_type

using traits_type = Traits

◆ value_type

using value_type = CharT

Constructor & Destructor Documentation

◆ basic_string_view() [1/9]

constexpr basic_string_view ( )
inlineconstexprnoexcept

◆ basic_string_view() [2/9]

constexpr basic_string_view ( const basic_string_view< CharT, Traits > &  other)
constexprdefaultnoexcept

◆ basic_string_view() [3/9]

constexpr basic_string_view ( const CharT *  s,
size_type  count 
)
inlineconstexpr

◆ basic_string_view() [4/9]

constexpr basic_string_view ( const CharT *  s)
inlineconstexpr

◆ basic_string_view() [5/9]

constexpr basic_string_view ( It  first,
End  last 
)
inlineconstexpr

◆ basic_string_view() [6/9]

constexpr basic_string_view ( R &&  r)
inlineexplicitconstexpr

◆ basic_string_view() [7/9]

constexpr basic_string_view ( const std::basic_string< CharT, Traits > &  s)
inlineconstexpr

◆ basic_string_view() [8/9]

constexpr basic_string_view ( std::basic_string< CharT, Traits > &&  s)
inlineconstexpr

◆ basic_string_view() [9/9]

constexpr basic_string_view ( std::nullptr_t  )
constexprdelete

Member Function Documentation

◆ at()

constexpr const_reference at ( size_type  pos) const
inlineconstexpr

◆ back()

constexpr const_reference back ( ) const
inlineconstexpr

◆ begin()

constexpr const_iterator begin ( ) const
inlineconstexprnoexcept

◆ cbegin()

constexpr const_iterator cbegin ( ) const
inlineconstexprnoexcept

◆ cend()

constexpr const_iterator cend ( ) const
inlineconstexprnoexcept

◆ compare() [1/6]

constexpr int compare ( basic_string_view< CharT, Traits >  other) const
inlineconstexprnoexcept

◆ compare() [2/6]

constexpr int compare ( const CharT *  s) const
inlineconstexpr

◆ compare() [3/6]

constexpr int compare ( size_type  pos1,
size_type  count1,
basic_string_view< CharT, Traits >  other 
) const
inlineconstexpr

◆ compare() [4/6]

constexpr int compare ( size_type  pos1,
size_type  count1,
basic_string_view< CharT, Traits >  other,
size_type  pos2,
size_type  count2 
) const
inlineconstexpr

◆ compare() [5/6]

constexpr int compare ( size_type  pos1,
size_type  count1,
const value_type s 
) const
inlineconstexpr

◆ compare() [6/6]

constexpr int compare ( size_type  pos1,
size_type  count1,
const value_type s,
size_type  count2 
) const
inlineconstexpr

◆ contains() [1/3]

constexpr bool contains ( basic_string_view< CharT, Traits >  sv) const
inlineconstexprnoexcept

◆ contains() [2/3]

constexpr bool contains ( const value_type str) const
inlineconstexpr

◆ contains() [3/3]

constexpr bool contains ( value_type  c) const
inlineconstexprnoexcept

◆ copy()

constexpr size_type copy ( value_type dest,
size_type  count,
size_type  pos = 0 
) const
inlineconstexpr

◆ crbegin()

constexpr const_reverse_iterator crbegin ( ) const
inlineconstexprnoexcept

◆ crend()

constexpr const_reverse_iterator crend ( ) const
inlineconstexprnoexcept

◆ data()

constexpr const_pointer data ( ) const
inlineconstexprnoexcept

◆ empty()

constexpr bool empty ( ) const
inlineconstexprnoexcept

◆ end()

constexpr const_iterator end ( ) const
inlineconstexprnoexcept

◆ ends_with() [1/3]

constexpr bool ends_with ( basic_string_view< CharT, Traits >  sv) const
inlineconstexprnoexcept

◆ ends_with() [2/3]

constexpr bool ends_with ( const value_type s) const
inlineconstexpr

◆ ends_with() [3/3]

constexpr bool ends_with ( value_type  c) const
inlineconstexprnoexcept

◆ find() [1/4]

constexpr size_type find ( basic_string_view< CharT, Traits >  sv,
size_type  pos = 0 
) const
inlineconstexprnoexcept

◆ find() [2/4]

constexpr size_type find ( const value_type str,
size_type  pos,
size_type  count 
) const
inlineconstexpr

◆ find() [3/4]

constexpr size_type find ( const value_type str,
size_type  pos = 0 
) const
inlineconstexpr

◆ find() [4/4]

constexpr size_type find ( value_type  c,
size_type  pos = 0 
) const
inlineconstexprnoexcept

◆ find_first_not_of() [1/4]

constexpr size_type find_first_not_of ( basic_string_view< CharT, Traits >  sv,
size_type  pos = 0 
) const
inlineconstexprnoexcept

◆ find_first_not_of() [2/4]

constexpr size_type find_first_not_of ( const value_type s,
size_type  pos,
size_type  count 
) const
inlineconstexpr

◆ find_first_not_of() [3/4]

constexpr size_type find_first_not_of ( const value_type s,
size_type  pos = 0 
) const
inlineconstexpr

◆ find_first_not_of() [4/4]

constexpr size_type find_first_not_of ( value_type  c,
size_type  pos = 0 
) const
inlineconstexprnoexcept

◆ find_first_of() [1/4]

constexpr size_type find_first_of ( basic_string_view< CharT, Traits >  sv,
size_type  pos = 0 
) const
inlineconstexprnoexcept

◆ find_first_of() [2/4]

constexpr size_type find_first_of ( const value_type s,
size_type  pos,
size_type  count 
) const
inlineconstexpr

◆ find_first_of() [3/4]

constexpr size_type find_first_of ( const value_type s,
size_type  pos = 0 
) const
inlineconstexpr

◆ find_first_of() [4/4]

constexpr size_type find_first_of ( value_type  c,
size_type  pos = 0 
) const
inlineconstexprnoexcept

◆ find_last_not_of() [1/4]

constexpr size_type find_last_not_of ( basic_string_view< CharT, Traits >  sv,
size_type  pos = npos 
) const
inlineconstexprnoexcept

◆ find_last_not_of() [2/4]

constexpr size_type find_last_not_of ( const value_type s,
size_type  pos,
size_type  count 
) const
inlineconstexpr

◆ find_last_not_of() [3/4]

constexpr size_type find_last_not_of ( const value_type s,
size_type  pos = npos 
) const
inlineconstexpr

◆ find_last_not_of() [4/4]

constexpr size_type find_last_not_of ( value_type  c,
size_type  pos = npos 
) const
inlineconstexprnoexcept

◆ find_last_of() [1/4]

constexpr size_type find_last_of ( basic_string_view< CharT, Traits >  sv,
size_type  pos = npos 
) const
inlineconstexprnoexcept

◆ find_last_of() [2/4]

constexpr size_type find_last_of ( const value_type s,
size_type  pos,
size_type  count 
) const
inlineconstexpr

◆ find_last_of() [3/4]

constexpr size_type find_last_of ( const value_type s,
size_type  pos = npos 
) const
inlineconstexpr

◆ find_last_of() [4/4]

constexpr size_type find_last_of ( value_type  c,
size_type  pos = npos 
) const
inlineconstexprnoexcept

◆ front()

constexpr const_reference front ( ) const
inlineconstexpr

◆ length()

constexpr size_type length ( ) const
inlineconstexprnoexcept

◆ max_size()

constexpr size_type max_size ( ) const
inlineconstexprnoexcept

◆ operator std::basic_string< CharT, Traits >()

operator std::basic_string< CharT, Traits > ( ) const
inlineexplicit

◆ operator=()

constexpr basic_string_view& operator= ( const basic_string_view< CharT, Traits > &  other)
constexprdefaultnoexcept

◆ operator[]()

constexpr const_reference operator[] ( size_type  pos) const
inlineconstexpr

Returns a const reference to the character at specified location pos. No bounds checking is performed: the behavior is undefined if pos >= size().

Parameters
posposition of the character to return
Returns
Const reference to the requested character.

◆ rbegin()

constexpr const_reverse_iterator rbegin ( ) const
inlineconstexprnoexcept

◆ remove_prefix()

constexpr void remove_prefix ( size_type  n)
inlineconstexpr

◆ remove_suffix()

constexpr void remove_suffix ( size_type  n)
inlineconstexpr

◆ rend()

constexpr const_reverse_iterator rend ( ) const
inlineconstexprnoexcept

◆ rfind() [1/4]

constexpr size_type rfind ( basic_string_view< CharT, Traits >  sv,
size_type  pos = npos 
) const
inlineconstexprnoexcept

◆ rfind() [2/4]

constexpr size_type rfind ( const value_type str,
size_type  pos,
size_type  count 
) const
inlineconstexpr

◆ rfind() [3/4]

constexpr size_type rfind ( const value_type str,
size_type  pos = npos 
) const
inlineconstexpr

◆ rfind() [4/4]

constexpr size_type rfind ( value_type  c,
size_type  pos = npos 
) const
inlineconstexprnoexcept

◆ size()

constexpr size_type size ( ) const
inlineconstexprnoexcept

◆ starts_with() [1/3]

constexpr bool starts_with ( basic_string_view< CharT, Traits >  prefix) const
inlineconstexprnoexcept

◆ starts_with() [2/3]

constexpr bool starts_with ( const value_type s) const
inlineconstexpr

◆ starts_with() [3/3]

constexpr bool starts_with ( value_type  c) const
inlineconstexprnoexcept

◆ substr()

constexpr basic_string_view substr ( size_type  pos = 0,
size_type  count = npos 
) const
inlineconstexpr

◆ swap()

constexpr void swap ( basic_string_view< CharT, Traits > &  other)
inlineconstexprnoexcept

Member Data Documentation

◆ npos

constexpr size_type npos = size_type(-1)
staticconstexpr

The documentation for this class was generated from the following file: