conststr 0.2.1
|
String type that can be evaluated in a constant context. More...
#include <conststr.hpp>
Public Member Functions | |
constexpr | cstr (const sv_selector< view_type > &svs={}) noexcept |
Default constructor, constructs string which is filled with '\0' . More... | |
constexpr | cstr (const value_type(&str)[N+1], const sv_selector< view_type > &svs={}) noexcept |
Construct string from string literal. More... | |
constexpr | cstr (const value_type &ch, const sv_selector< view_type > &svs={}) noexcept |
Construct string with N copies of character ch . More... | |
constexpr | cstr (std::convertible_to< value_type > auto... vs) |
Constructor for variable template parameter pack expansion. More... | |
constexpr | cstr (const cstr &)=default |
Copy constructor. | |
template<typename V2 > | |
constexpr | cstr (const cstr< N, value_type, V2 > &other) |
Copy from another string with different view type. | |
constexpr | ~cstr ()=default |
Destructor. In fact, it does nothing. | |
template<can_construct_cstr_t_n_from< value_type, N > Str> | |
constexpr cstr & | operator= (const Str &str) |
Replaces the contents with a copy of another string. | |
constexpr void | fill (const value_type &ch) noexcept |
Fill the string with the character ch . More... | |
template<typename V2 > | |
constexpr void | swap (cstr< N, value_type, V2 > &other) noexcept |
Swap the contents of this string with another string. More... | |
constexpr pointer | data () noexcept |
Get the pointer of the underlying array serving as the character storage. More... | |
constexpr const_pointer | data () const noexcept |
Get the pointer of the underlying array serving as the character storage. More... | |
constexpr const_pointer | c_str () const noexcept |
Get the pointer to a null-terminated character array of contents. Always the same as data() . More... | |
constexpr iterator | begin () noexcept |
Get an iterator to the first character of the string. More... | |
constexpr const_iterator | begin () const noexcept |
Get an iterator to the first character of the string. More... | |
constexpr iterator | end () noexcept |
Get an iterator to the character following the last character of the string. More... | |
constexpr const_iterator | end () const noexcept |
Get an iterator to the character following the last character of the string. More... | |
constexpr const_iterator | cbegin () const noexcept |
Get an const iterator to the first character of the string. More... | |
constexpr const_iterator | cend () const noexcept |
Get an const iterator to the character following the last character of the string. More... | |
constexpr reverse_iterator | rbegin () noexcept |
Get a reverse iterator to the first character of the reversed string. More... | |
constexpr const_reverse_iterator | rbegin () const noexcept |
Get a reverse iterator to the first character of the reversed string. More... | |
constexpr reverse_iterator | rend () noexcept |
Get a reverse iterator to the character following the last character of the reversed string. More... | |
constexpr const_reverse_iterator | rend () const noexcept |
Get a reverse iterator to the character following the last character of the reversed string. More... | |
constexpr const_reverse_iterator | crbegin () const noexcept |
Get a const reverse iterator to the first character of the reversed string. More... | |
constexpr const_reverse_iterator | crend () const noexcept |
Get a const reverse iterator to the character following the last character of the reversed string. More... | |
constexpr reference | operator[] (size_type pos) noexcept |
Get the reference to the character at specified location pos . More... | |
constexpr const_reference | operator[] (size_type pos) const noexcept |
Get the reference to the character at specified location pos . More... | |
template<size_type Idx> requires (N > Idx) | |
constexpr reference | get () &noexcept |
Tuple-like interface, extracts the Idx-th element from the string. More... | |
template<size_type Idx> requires (N > Idx) | |
constexpr const_reference | get () const &noexcept |
Tuple-like interface, extracts the Idx-th element from the string. More... | |
template<size_type Idx> requires (N > Idx) | |
constexpr rreference | get () &&noexcept |
Tuple-like interface, extracts the Idx-th element from the string. More... | |
template<size_type Idx> requires (N > Idx) | |
constexpr const_rreference | get () const &&noexcept |
Tuple-like interface, extracts the Idx-th element from the string. More... | |
constexpr reference | front () noexcept |
Get the reference to the first character in the string. More... | |
constexpr const_reference | front () const noexcept |
Get the reference to the first character in the string. More... | |
constexpr reference | back () noexcept |
Get the reference to the last character in the string. More... | |
constexpr const_reference | back () const noexcept |
Get the reference to the last character in the string. More... | |
template<can_construct_cstr_t_from< value_type > Str> | |
constexpr auto | operator+ (const Str &str) const noexcept |
Concatenate the contents with another string. More... | |
template<std::size_t N2, typename V2 > | |
constexpr bool | operator== (const cstr< N2, value_type, V2 > &other) const noexcept |
Check if the contents of two strings are the same. More... | |
template<typename V2 > | |
constexpr bool | operator== (const cstr< N, value_type, V2 > &other) const noexcept |
Check if the contents of two strings are the same. More... | |
constexpr bool | operator== (const view_type &other) const noexcept |
Check if the contents of two strings are the same. More... | |
template<std::size_t N2, typename V2 > | |
constexpr auto | operator<=> (const cstr< N2, value_type, V2 > &other) noexcept |
Compares the contents of two strings lexicographically. More... | |
constexpr auto | operator<=> (const view_type &other) const noexcept |
Compares the contents of two strings lexicographically. More... | |
constexpr | operator view_type () const noexcept |
Implicit conversion to the view type. | |
template<meta::viewer< value_type, size_type > V2> | |
constexpr auto | with_view () const noexcept -> cstr< N, value_type, V2 > |
Change view type. More... | |
template<size_type Start, size_type Len = N> requires (N >= Start) | |
constexpr auto | substr () const noexcept |
Get the substring. More... | |
template<size_type Len> | |
constexpr auto | cut () const noexcept -> cstr< Len, value_type, view_type > |
Get the substring containing first Len characters. Always be equivalent to substr<0, Len>() . More... | |
template<size_type Len> | |
constexpr auto | remove_prefix () const noexcept |
Remove Len bytes of prefix. Always be equivalent to substr<Len>() . More... | |
template<size_type Len> | |
constexpr auto | remove_suffix () const noexcept |
Remove Len bytes of suffix. Always be equivalent to substr<0, size() - Len>() . More... | |
template<size_type Count = 1> | |
constexpr auto | insert (size_type pos, const value_type &ch) const noexcept -> cstr< N+Count, value_type, view_type > |
Insert Count copies of character ch at the position pos . More... | |
template<size_type Count = 1> | |
constexpr auto | insert (const_iterator iter, const value_type &ch) const noexcept -> cstr< N+Count, value_type, view_type > |
Insert Count copies of character ch before iterator iter . More... | |
template<can_construct_cstr_t_from< value_type > Str> | |
constexpr auto | insert (size_type pos, const Str &str) const noexcept |
Insert another string at the position pos . More... | |
template<can_construct_cstr_t_from< value_type > Str> | |
constexpr auto | insert (const_iterator iter, const Str &str) const noexcept |
Insert another string before iterator iter . More... | |
template<size_type Count = 1> | |
constexpr auto | append (const value_type &ch) const noexcept -> cstr< N+Count, value_type, view_type > |
Append Count copies of character ch at the end. More... | |
template<can_construct_cstr_t_from< value_type > Str> | |
constexpr auto | append (const Str &str) const noexcept |
Append another string at the end. More... | |
template<size_type... Sizes> | |
constexpr auto | flatten (const cstr< Sizes, value_type, view_type > &...strs) const noexcept |
Flatten multiple strings of different lengths. More... | |
template<can_construct_cstr_t_from< value_type >... Strs> | |
constexpr auto | flatten (const Strs &...strs) const noexcept |
Flatten multiple strings of different lengths. More... | |
constexpr auto | replace (size_type pos, const value_type &ch, size_type count=1) const noexcept -> cstr< N, value_type, view_type > |
Replaces the characters in the range [pos , min(pos + count, size()) ) with character ch . More... | |
constexpr auto | replace (const_iterator first, const_iterator last, const value_type &ch) const noexcept -> cstr< N, value_type, view_type > |
Replaces the characters in the range [max(first, cbegin()) , min(last, cend()) ) with character ch . More... | |
constexpr auto | replace (size_type pos, const view_type &str, size_type count=1) const noexcept -> cstr< N, value_type, view_type > |
Replaces the characters in the range [pos , min(pos + str.size() * count, size()) ) with another string str . More... | |
constexpr auto | replace (const_iterator first, const_iterator last, const view_type &str) const noexcept -> cstr< N, value_type, view_type > |
Replaces the characters in the range [max(first, cbegin()) , min(last, cend()) ) with another string str . More... | |
template<value_type... Chs> | |
constexpr auto | replace (size_type pos=0, size_type len=N) const noexcept -> cstr< N, value_type, view_type > requires(sizeof...(Chs) > 0) |
Replaces the characters in the range [pos , min(pos + len, size()) ) according to variable template parameters. More... | |
template<value_type... Chs> | |
constexpr auto | replace (const_iterator first, const_iterator last) const noexcept -> cstr< N, value_type, view_type > requires(sizeof...(Chs) > 0) |
Replaces the characters in the range [max(first, cbegin()) , min(last, cend()) ) according to variable template parameters. More... | |
constexpr auto | erase (size_type pos) const noexcept -> cstr< N - 1, value_type, view_type > |
Remove the character at position pos . More... | |
constexpr auto | erase (const_iterator iter) const noexcept -> cstr< N - 1, value_type, view_type > |
Remove the character pointed by iter . More... | |
constexpr auto | push (const value_type &ch) const noexcept -> cstr< N+1, value_type > |
Push a character to the end of string. Always be equivalent to append(ch) . More... | |
constexpr auto | pop () const noexcept -> cstr< N - 1, value_type, view_type > |
Pop the last character from the end of string. Always be equivalent to cut<size() - 1>() . More... | |
template<typename UnaryOperation , typename V2 = void> requires (meta::viewer<V2, operation_result<UnaryOperation>> || (std::is_void_v<V2>)) | |
constexpr auto | transform (UnaryOperation op, size_type pos=0, size_type len=N, const sv_selector< V2 > &svs={}) const noexcept |
Apply the given function to each character in the range [pos , min(pos + len, size()) ). More... | |
template<typename UnaryOperation , typename V2 = void> requires (meta::viewer<V2, operation_result<UnaryOperation>> || (std::is_void_v<V2>)) | |
constexpr auto | transform (UnaryOperation op, const_iterator first, const_iterator last, const sv_selector< V2 > &svs={}) const noexcept |
Apply the given function to each character in the range [first , min(last, cend()) ). More... | |
template<charutils::char_like T2, typename V2 = void> requires (meta::viewer<V2, T2> || (std::is_void_v<V2>)) | |
constexpr auto | cast (const sv_selector< V2 > &svs={}) const noexcept |
Convert character type. Always be equivalent to transform(charutils::cast<T2>, 0, N, sv<V2>) . More... | |
constexpr auto | uppercase () const noexcept -> cstr< N, value_type, view_type > |
Convert all characters to uppercase. Always be equivalent to transform(charutils::toupper<value_type>) . More... | |
constexpr auto | lowercase () const noexcept -> cstr< N, value_type, view_type > |
Convert all characters to lowercase. Always be equivalent to transform(charutils::tolower<value_type>) . More... | |
constexpr size_type | find (const value_type &ch, size_type pos=0) const noexcept |
Find the first character equal to the given character. More... | |
constexpr size_type | find (const view_type &str, size_type pos=0) const noexcept |
Find the first substring equal to the given substring. More... | |
constexpr size_type | rfind (const value_type &ch, size_type pos=npos) const noexcept |
Find the last character equal to the given character. More... | |
constexpr size_type | rfind (const view_type &str, size_type pos=npos) const noexcept |
Find the last substring equal to the given substring. More... | |
template<typename UnaryPredicate > | |
constexpr size_type | find_if (UnaryPredicate p, size_type pos=0) const noexcept |
Find the first character for which predicate p returns true . More... | |
template<typename UnaryPredicate > | |
constexpr size_type | rfind_if (UnaryPredicate p, size_type pos=npos) const noexcept |
Find the last character for which predicate p returns true . More... | |
constexpr bool | starts_with (const value_type &ch) const noexcept |
Check if the string begins with the given character. More... | |
constexpr bool | starts_with (const view_type &str) const noexcept |
Check if the string begins with the given substring. More... | |
constexpr bool | ends_with (const value_type &ch) const noexcept |
Check if the string ends with the given character. More... | |
constexpr bool | ends_with (const view_type &str) const noexcept |
Check if the string ends with the given substring. More... | |
constexpr bool | contains (const value_type &ch) const noexcept |
Check if the string contains the given character. Always be equivalent to find(ch) != npos . More... | |
constexpr bool | contains (const view_type &str) const noexcept |
Check if the string contains the given substring. Always be equivalent to find(str) != npos . More... | |
Static Public Member Functions | |
static constexpr size_type | size () noexcept |
Get size of string, without counting the null terminator. More... | |
static constexpr size_type | length () noexcept |
Alternative API of size() . Get size of string, without counting the null terminator. More... | |
static constexpr size_type | max_size () noexcept |
Get the maximum number of characters the string is able to hold. Always the same as size() . More... | |
static constexpr bool | empty () noexcept |
Checks if string is empty. More... | |
Public Attributes | |
value_type | _str [N+1] |
Underlying storage. Unless absolutely necessary, you should not access it directly. Instead, you should use begin() and end() . | |
Static Public Attributes | |
static constexpr value_type | nul = value_type('\0') |
Null terminator with the value '\0' . | |
static constexpr size_type | npos = N |
Indicator of the end of string. | |
String type that can be evaluated in a constant context.
Very similar to std::array<char, N>
, but null terminator will be added.
N | size of string, without counting the null terminator |
T | character type, default to char |
view | view type of T , default to std::basic_string_view<T> |
|
inlineconstexprnoexcept |
Default constructor, constructs string which is filled with '\0'
.
svs | string view type selector, default view type is std::basic_string_view |
|
inlineconstexprnoexcept |
Construct string from string literal.
This is the most commonly used construction method. Just simply use cstr("blabla")
to construct the cstr
without worrying about the template type.
"blabla"_cs
. str | the input string array/literal |
svs | string view type selector, default view type is std::basic_string_view |
|
inlineconstexprnoexcept |
Construct string with N
copies of character ch
.
ch | the character to fill |
svs | string view type selector, default view type is std::basic_string_view |
|
inlineconstexpr |
Constructor for variable template parameter pack expansion.
For example, cstr<sizeof...(chs)> s = { chs... };
.
|
inlineconstexprnoexcept |
Append another string at the end.
*this
, but returns the modified string. Str | type of another string |
str | another string to append |
|
inlineconstexprnoexcept |
Append Count
copies of character ch
at the end.
*this
, but returns the modified string. Count | count of appending, default to 1 |
ch | character to append |
|
inlineconstexprnoexcept |
Get the reference to the last character in the string.
|
inlineconstexprnoexcept |
Get the reference to the last character in the string.
|
inlineconstexprnoexcept |
Get an iterator to the first character of the string.
|
inlineconstexprnoexcept |
Get an iterator to the first character of the string.
|
inlineconstexprnoexcept |
Get the pointer to a null-terminated character array of contents. Always the same as data()
.
|
inlineconstexprnoexcept |
Convert character type. Always be equivalent to transform(charutils::cast<T2>, 0, N, sv<V2>)
.
T2 | another character type |
V2 | view type of output string |
svs | string view type selector |
|
inlineconstexprnoexcept |
Get an const iterator to the first character of the string.
|
inlineconstexprnoexcept |
Get an const iterator to the character following the last character of the string.
|
inlineconstexprnoexcept |
Check if the string contains the given character. Always be equivalent to find(ch) != npos
.
ch | any character |
true
if the string contains the provided character. false
otherwise.
|
inlineconstexprnoexcept |
Check if the string contains the given substring. Always be equivalent to find(str) != npos
.
str | any string |
true
if the string contains the provided substring. false
otherwise.
|
inlineconstexprnoexcept |
Get a const reverse iterator to the first character of the reversed string.
|
inlineconstexprnoexcept |
Get a const reverse iterator to the character following the last character of the reversed string.
|
inlineconstexprnoexcept |
Get the substring containing first Len
characters. Always be equivalent to substr<0, Len>()
.
Len | length of the sub string. |
Len
) or [0, size()
).
|
inlineconstexprnoexcept |
Get the pointer of the underlying array serving as the character storage.
|
inlineconstexprnoexcept |
Get the pointer of the underlying array serving as the character storage.
|
inlinestaticconstexprnoexcept |
Checks if string is empty.
true
if string is empty. false
otherwise.
|
inlineconstexprnoexcept |
Get an iterator to the character following the last character of the string.
|
inlineconstexprnoexcept |
Get an iterator to the character following the last character of the string.
|
inlineconstexprnoexcept |
Check if the string ends with the given character.
ch | any character |
true
if the string ends with the provided character. false
otherwise.
|
inlineconstexprnoexcept |
Check if the string ends with the given substring.
str | any string |
true
if the string ends with the provided substring. false
otherwise.
|
inlineconstexprnoexcept |
Remove the character pointed by iter
.
iter
is out-of-range, the first or the last character will be removed. *this
, but returns the modified string. iter | iterator which points to the character that will be removed |
|
inlineconstexprnoexcept |
Remove the character at position pos
.
pos
is greater than or equal to size()
, the last character will be removed. *this
, but returns the modified string. pos | position of the character to be removed |
|
inlineconstexprnoexcept |
Fill the string with the character ch
.
ch | character to be used to fill the string |
|
inlineconstexprnoexcept |
Find the first character equal to the given character.
ch | character to search for |
pos | position at which to start the search |
npos
if not found.
|
inlineconstexprnoexcept |
Find the first substring equal to the given substring.
str | substring to search for |
pos | position at which to start the search |
npos
if not found.
|
inlineconstexprnoexcept |
Find the first character for which predicate p
returns true
.
UnaryPredicate | type of the unary predicate function |
p | unary predicate function object which returns true for the required element. |
pos | position at which to start the search |
npos
if not found.
|
inlineconstexprnoexcept |
Flatten multiple strings of different lengths.
flatten()
function to better suit metaprogramming. *this
, but returns the modified string. strs | strings to be flattened |
|
inlineconstexprnoexcept |
Flatten multiple strings of different lengths.
flatten()
function to better suit metaprogramming. *this
, but returns the modified string. Strs | types of strings |
strs | strings to be flattened |
|
inlineconstexprnoexcept |
Get the reference to the first character in the string.
|
inlineconstexprnoexcept |
Get the reference to the first character in the string.
|
inlineconstexprnoexcept |
Tuple-like interface, extracts the Idx-th element from the string.
Idx | position of the character |
|
inlineconstexprnoexcept |
Tuple-like interface, extracts the Idx-th element from the string.
Idx | position of the character |
|
inlineconstexprnoexcept |
Tuple-like interface, extracts the Idx-th element from the string.
Idx | position of the character |
|
inlineconstexprnoexcept |
Tuple-like interface, extracts the Idx-th element from the string.
Idx | position of the character |
|
inlineconstexprnoexcept |
Insert another string before iterator iter
.
*this
, but returns the modified string. Str | type of another string |
iter | iterator before which the characters will be inserted |
str | string to insert |
|
inlineconstexprnoexcept |
Insert Count
copies of character ch
before iterator iter
.
*this
, but returns the modified string. Count | count of insertion, default to 1 |
iter | iterator before which the characters will be inserted |
ch | character to insert |
|
inlineconstexprnoexcept |
Insert another string at the position pos
.
*this
, but returns the modified string. Str | type of another string |
pos | position that the characters will be inserted |
str | string to insert |
|
inlineconstexprnoexcept |
Insert Count
copies of character ch
at the position pos
.
*this
, but returns the modified string. Count | count of insertion, default to 1 |
pos | position that the characters will be inserted |
ch | character to insert |
|
inlinestaticconstexprnoexcept |
Alternative API of size()
. Get size of string, without counting the null terminator.
|
inlineconstexprnoexcept |
Convert all characters to lowercase. Always be equivalent to transform(charutils::tolower<value_type>)
.
*this
, but returns the modified string. If you really want to modify current string, use std::transform(str.begin(), str.end(), str.begin(), charutils::tolower<T>)
.
|
inlinestaticconstexprnoexcept |
Get the maximum number of characters the string is able to hold. Always the same as size()
.
|
inlineconstexprnoexcept |
Concatenate the contents with another string.
Str | type of another string |
str | another string to be concatenated |
|
inlineconstexprnoexcept |
Compares the contents of two strings lexicographically.
s1 <=> s2
directly, this operator will automatically derive other logical operators: >
, <
, >=
and <=
. N2 | size of another string |
V2 | view type of another string |
other | another string to be compared |
|
inlineconstexprnoexcept |
Compares the contents of two strings lexicographically.
s1 <=> s2
directly, this operator will automatically derive other logical operators: >
, <
, >=
and <=
. other | another string to be compared |
|
inlineconstexprnoexcept |
Check if the contents of two strings are the same.
V2 | view type of another string |
other | another string to be compared |
true
if the contents of two strings are the same. false
otherwise.
|
inlineconstexprnoexcept |
Check if the contents of two strings are the same.
N2 | size of another string |
V2 | view type of another string |
other | another string to be compared |
false
always in this overloaded version.
|
inlineconstexprnoexcept |
Check if the contents of two strings are the same.
other | another string to be compared |
true
if the contents of two strings are the same. false
otherwise.
|
inlineconstexprnoexcept |
Get the reference to the character at specified location pos
.
pos | position of the character |
|
inlineconstexprnoexcept |
Get the reference to the character at specified location pos
.
pos | position of the character to return |
|
inlineconstexprnoexcept |
Pop the last character from the end of string. Always be equivalent to cut<size() - 1>()
.
*this
, but returns the modified string.
|
inlineconstexprnoexcept |
Push a character to the end of string. Always be equivalent to append(ch)
.
*this
, but returns the modified string. ch | character to be pushed |
|
inlineconstexprnoexcept |
Get a reverse iterator to the first character of the reversed string.
|
inlineconstexprnoexcept |
Get a reverse iterator to the first character of the reversed string.
|
inlineconstexprnoexcept |
Remove Len
bytes of prefix. Always be equivalent to substr<Len>()
.
Len | bytes of prefix to remove |
Len
, size()
).
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Get a reverse iterator to the character following the last character of the reversed string.
|
inlineconstexprnoexcept |
Get a reverse iterator to the character following the last character of the reversed string.
|
inlineconstexprnoexcept |
Replaces the characters in the range [max(first, cbegin())
, min(last, cend())
) according to variable template parameters.
For example, str.replace<'a', 'b', 'c', 'd'>(...)
replaces 'a'
, 'b'
and 'c'
in the contents of string to 'd'
. Always be equivalent to transform(charutils::replace<Chs...>, first, last)
.
*this
, but returns the modified string. If you really want to modify current string, use std::transform(first, last, first, charutils::replace<Chs...>)
while first
and last
are iterators of current string. Chs | characters for replacement, see the example |
first | begin of range of characters that is going to be replaced |
last | end of range of characters that is going to be replaced |
|
inlineconstexprnoexcept |
Replaces the characters in the range [max(first, cbegin())
, min(last, cend())
) with character ch
.
*this
, but returns the modified string. If you really want to modify current string, use ‘std::transform(first, last, first, charutils::just<'a’>)while
firstand
last` are iterators of current string. first | begin of range of characters that is going to be replaced |
last | end of range of characters that is going to be replaced |
ch | character value to use for replacement |
|
inlineconstexprnoexcept |
Replaces the characters in the range [max(first, cbegin())
, min(last, cend())
) with another string str
.
*this
, but returns the modified string. first | begin of range of characters that is going to be replaced |
last | end of range of characters that is going to be replaced |
str | string to use for replacement |
|
inlineconstexprnoexcept |
Replaces the characters in the range [pos
, min(pos + count, size())
) with character ch
.
*this
, but returns the modified string. If you really want to modify current string, use ‘std::transform(first, last, first, charutils::just<'a’>)while
firstand
last` are iterators of current string. pos | start of the substring that is going to be replaced |
ch | character value to use for replacement |
count | length of the substring that is going to be replaced |
|
inlineconstexprnoexcept |
Replaces the characters in the range [pos
, min(pos + str.size() * count, size())
) with another string str
.
*this
, but returns the modified string. pos | start of the substring that is going to be replaced |
str | string to use for replacement |
count | replacement times of str |
|
inlineconstexprnoexcept |
Replaces the characters in the range [pos
, min(pos + len, size())
) according to variable template parameters.
For example, str.replace<'a', 'b', 'c', 'd'>(...)
replaces 'a'
, 'b'
and 'c'
in the contents of string to 'd'
. Always be equivalent to transform(charutils::replace<Chs...>, pos, len)
.
*this
, but returns the modified string. If you really want to modify current string, use std::transform(first, last, first, charutils::replace<Chs...>)
while first
and last
are iterators of current string. Chs | characters for replacement, see the example |
pos | start of the substring that is going to be replaced |
len | length of the substring that is going to be replaced |
|
inlineconstexprnoexcept |
Find the last character equal to the given character.
ch | character to search for |
pos | position at which to start the search |
npos
if not found.
|
inlineconstexprnoexcept |
Find the last substring equal to the given substring.
str | substring to search for |
pos | position at which to start the search |
npos
if not found.
|
inlineconstexprnoexcept |
Find the last character for which predicate p
returns true
.
UnaryPredicate | type of the unary predicate function |
p | unary predicate function object which returns true for the required element. |
pos | position at which to start the search |
npos
if not found.
|
inlinestaticconstexprnoexcept |
Get size of string, without counting the null terminator.
|
inlineconstexprnoexcept |
Check if the string begins with the given character.
ch | any character |
true
if the string begins with the provided character. false
otherwise.
|
inlineconstexprnoexcept |
Check if the string begins with the given substring.
str | any string |
true
if the string begins with the provided substring. false
otherwise.
|
inlineconstexprnoexcept |
Get the substring.
Start | position of the first character |
Len | length of the substring |
Start
, Start + Len
) or [Start
, size()
).
|
inlineconstexprnoexcept |
Swap the contents of this string with another string.
V2 | view type of another string |
other | another string to swap the contents |
|
inlineconstexprnoexcept |
Apply the given function to each character in the range [first
, min(last, cend())
).
*this
, but returns the modified string. If you really want to modify current string, use std::transform(str.begin(), str.end(), str.begin(), op)
. UnaryOperation | type of the unary operation function |
V2 | view type for the transform result, by default, if return type Ret of the unary operation op is the same as the original value type, then the view type is left unchanged, otherwise it is std::basic_string_view<Ret> |
op | unary operation function object that will be applied, the signature of the function should be Ret f(const T &) or Ret f(T) . |
first | iterator to the start position of the range |
last | iterator to the end position of the range |
svs | string view type selector |
|
inlineconstexprnoexcept |
Apply the given function to each character in the range [pos
, min(pos + len, size())
).
*this
, but returns the modified string. If you really want to modify current string, use std::transform(str.begin(), str.end(), str.begin(), op)
. UnaryOperation | type of the unary operation function |
V | view type for the transform result, by default, if return type Ret of the unary operation op is the same as the original value type, then the view type is left unchanged, otherwise it is std::basic_string_view<Ret> |
op | unary operation function object that will be applied, the signature of the function should be Ret f(const T &) or Ret f(T) . |
pos | start position of the range |
len | count of character to be handled |
svs | string view type selector |
|
inlineconstexprnoexcept |
Convert all characters to uppercase. Always be equivalent to transform(charutils::toupper<value_type>)
.
*this
, but returns the modified string. If you really want to modify current string, use std::transform(str.begin(), str.end(), str.begin(), charutils::toupper<T>)
.
|
inlineconstexprnoexcept |
Change view type.
V2 | new view type |