conststr 0.2.1
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
conststr::cstr< N, T, view > Struct Template Reference

String type that can be evaluated in a constant context. More...

#include <conststr.hpp>

Public Types

using value_type = T
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using reference = value_type &
 
using const_reference = const value_type &
 
using rreference = value_type &&
 
using const_rreference = const value_type &&
 
using pointer = value_type *
 
using const_pointer = const value_type *
 
using iterator = value_type *
 
using const_iterator = const value_type *
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using view_type = view
 
template<typename UnaryOperation >
using operation_result = std::remove_cvref_t< std::invoke_result_t< UnaryOperation, value_type > >
 

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 cstroperator= (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.
 

Detailed Description

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
requires meta::viewer<view, T>
struct conststr::cstr< N, T, view >

String type that can be evaluated in a constant context.

Very similar to std::array<char, N>, but null terminator will be added.

Note
When you iterate over it, the null terminator is not in range.
Template Parameters
Nsize of string, without counting the null terminator
Tcharacter type, default to char
viewview type of T, default to std::basic_string_view<T>

Constructor & Destructor Documentation

◆ cstr() [1/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr conststr::cstr< N, T, view >::cstr ( const sv_selector< view_type > &  svs = {})
inlineconstexprnoexcept

Default constructor, constructs string which is filled with '\0'.

Parameters
svsstring view type selector, default view type is std::basic_string_view
See also
sv

◆ cstr() [2/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr conststr::cstr< N, T, view >::cstr ( const value_type(&)  str[N+1],
const sv_selector< view_type > &  svs = {} 
)
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.

Note
A simpler way is to use the user-defined string literal like "blabla"_cs.
Parameters
strthe input string array/literal
svsstring view type selector, default view type is std::basic_string_view
See also
conststr::literal
sv

◆ cstr() [3/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr conststr::cstr< N, T, view >::cstr ( const value_type &  ch,
const sv_selector< view_type > &  svs = {} 
)
inlineconstexprnoexcept

Construct string with N copies of character ch.

Parameters
chthe character to fill
svsstring view type selector, default view type is std::basic_string_view
See also
sv

◆ cstr() [4/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr conststr::cstr< N, T, view >::cstr ( std::convertible_to< value_type > auto...  vs)
inlineconstexpr

Constructor for variable template parameter pack expansion.

For example, cstr<sizeof...(chs)> s = { chs... };.

Note
A null terminator will be added to the end.

Member Function Documentation

◆ append() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<can_construct_cstr_t_from< value_type > Str>
constexpr auto conststr::cstr< N, T, view >::append ( const Str &  str) const
inlineconstexprnoexcept

Append another string at the end.

Note
This method changes the string length, therefore it does not change *this, but returns the modified string.
Template Parameters
Strtype of another string
Parameters
stranother string to append
Returns
The modified string.

◆ append() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Count = 1>
constexpr auto conststr::cstr< N, T, view >::append ( const value_type &  ch) const -> cstr<N + Count, value_type, view_type>
inlineconstexprnoexcept

Append Count copies of character ch at the end.

Note
This method changes the string length, therefore it does not change *this, but returns the modified string.
Template Parameters
Countcount of appending, default to 1
Parameters
chcharacter to append
Returns
The modified string.

◆ back() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_reference conststr::cstr< N, T, view >::back ( ) const
inlineconstexprnoexcept

Get the reference to the last character in the string.

Note
Reference to null terminator will be returned if string is empty.
Returns
Reference to the last character.

◆ back() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr reference conststr::cstr< N, T, view >::back ( )
inlineconstexprnoexcept

Get the reference to the last character in the string.

Note
Reference to null terminator will be returned if string is empty.
Returns
Reference to the last character.

◆ begin() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_iterator conststr::cstr< N, T, view >::begin ( ) const
inlineconstexprnoexcept

Get an iterator to the first character of the string.

Returns
Iterator to the first character.

◆ begin() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr iterator conststr::cstr< N, T, view >::begin ( )
inlineconstexprnoexcept

Get an iterator to the first character of the string.

Returns
Iterator to the first character.

◆ c_str()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_pointer conststr::cstr< N, T, view >::c_str ( ) const
inlineconstexprnoexcept

Get the pointer to a null-terminated character array of contents. Always the same as data().

Returns
A pointer to the underlying character storage.

◆ cast()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<charutils::char_like T2, typename V2 = void>
requires (meta::viewer<V2, T2> || (std::is_void_v<V2>))
constexpr auto conststr::cstr< N, T, view >::cast ( const sv_selector< V2 > &  svs = {}) const
inlineconstexprnoexcept

Convert character type. Always be equivalent to transform(charutils::cast<T2>, 0, N, sv<V2>).

Template Parameters
T2another character type
V2view type of output string
Parameters
svsstring view type selector
Returns
String with another character type.
See also
sv

◆ cbegin()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_iterator conststr::cstr< N, T, view >::cbegin ( ) const
inlineconstexprnoexcept

Get an const iterator to the first character of the string.

Returns
Const iterator to the first character.

◆ cend()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_iterator conststr::cstr< N, T, view >::cend ( ) const
inlineconstexprnoexcept

Get an const iterator to the character following the last character of the string.

Returns
Const iterator to the character following the last character.

◆ contains() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr bool conststr::cstr< N, T, view >::contains ( const value_type &  ch) const
inlineconstexprnoexcept

Check if the string contains the given character. Always be equivalent to find(ch) != npos.

Parameters
chany character
Returns
true if the string contains the provided character.
false otherwise.

◆ contains() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr bool conststr::cstr< N, T, view >::contains ( const view_type &  str) const
inlineconstexprnoexcept

Check if the string contains the given substring. Always be equivalent to find(str) != npos.

Parameters
strany string
Returns
true if the string contains the provided substring.
false otherwise.

◆ crbegin()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_reverse_iterator conststr::cstr< N, T, view >::crbegin ( ) const
inlineconstexprnoexcept

Get a const reverse iterator to the first character of the reversed string.

Returns
Const reverse iterator to the first character.

◆ crend()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_reverse_iterator conststr::cstr< N, T, view >::crend ( ) const
inlineconstexprnoexcept

Get a const reverse iterator to the character following the last character of the reversed string.

Returns
Const reverse iterator to the character following the last character.

◆ cut()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Len>
constexpr auto conststr::cstr< N, T, view >::cut ( ) const -> cstr<Len, value_type, view_type>
inlineconstexprnoexcept

Get the substring containing first Len characters. Always be equivalent to substr<0, Len>().

Template Parameters
Lenlength of the sub string.
Returns
The substring [0, Len) or [0, size()).

◆ data() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_pointer conststr::cstr< N, T, view >::data ( ) const
inlineconstexprnoexcept

Get the pointer of the underlying array serving as the character storage.

Returns
A pointer to the underlying character storage.

◆ data() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr pointer conststr::cstr< N, T, view >::data ( )
inlineconstexprnoexcept

Get the pointer of the underlying array serving as the character storage.

Returns
A pointer to the underlying character storage.

◆ empty()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
static constexpr bool conststr::cstr< N, T, view >::empty ( )
inlinestaticconstexprnoexcept

Checks if string is empty.

Note
This means that the length ot string is 0 instead of the first character is the null terminator.
Returns
true if string is empty.
false otherwise.

◆ end() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_iterator conststr::cstr< N, T, view >::end ( ) const
inlineconstexprnoexcept

Get an iterator to the character following the last character of the string.

Returns
Iterator to the character following the last character.

◆ end() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr iterator conststr::cstr< N, T, view >::end ( )
inlineconstexprnoexcept

Get an iterator to the character following the last character of the string.

Returns
Iterator to the character following the last character.

◆ ends_with() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr bool conststr::cstr< N, T, view >::ends_with ( const value_type &  ch) const
inlineconstexprnoexcept

Check if the string ends with the given character.

Parameters
chany character
Returns
true if the string ends with the provided character.
false otherwise.

◆ ends_with() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr bool conststr::cstr< N, T, view >::ends_with ( const view_type &  str) const
inlineconstexprnoexcept

Check if the string ends with the given substring.

Parameters
strany string
Returns
true if the string ends with the provided substring.
false otherwise.

◆ erase() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::erase ( const_iterator  iter) const -> cstr<N - 1, value_type, view_type>
inlineconstexprnoexcept

Remove the character pointed by iter.

Note
If iter is out-of-range, the first or the last character will be removed.
This method changes the string length, therefore it does not change *this, but returns the modified string.
Parameters
iteriterator which points to the character that will be removed
Returns
The modified string.

◆ erase() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::erase ( size_type  pos) const -> cstr<N - 1, value_type, view_type>
inlineconstexprnoexcept

Remove the character at position pos.

Note
If pos is greater than or equal to size(), the last character will be removed.
This method changes the string length, therefore it does not change *this, but returns the modified string.
Parameters
posposition of the character to be removed
Returns
The modified string.

◆ fill()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr void conststr::cstr< N, T, view >::fill ( const value_type &  ch)
inlineconstexprnoexcept

Fill the string with the character ch.

Parameters
chcharacter to be used to fill the string

◆ find() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr size_type conststr::cstr< N, T, view >::find ( const value_type &  ch,
size_type  pos = 0 
) const
inlineconstexprnoexcept

Find the first character equal to the given character.

Parameters
chcharacter to search for
posposition at which to start the search
Returns
Position of the found character or npos if not found.

◆ find() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr size_type conststr::cstr< N, T, view >::find ( const view_type &  str,
size_type  pos = 0 
) const
inlineconstexprnoexcept

Find the first substring equal to the given substring.

Parameters
strsubstring to search for
posposition at which to start the search
Returns
Position of the first character of the found substring or npos if not found.

◆ find_if()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<typename UnaryPredicate >
constexpr size_type conststr::cstr< N, T, view >::find_if ( UnaryPredicate  p,
size_type  pos = 0 
) const
inlineconstexprnoexcept

Find the first character for which predicate p returns true.

Template Parameters
UnaryPredicatetype of the unary predicate function
Parameters
punary predicate function object which returns true for the required element.
posposition at which to start the search
Returns
Position of the found character or npos if not found.

◆ flatten() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type... Sizes>
constexpr auto conststr::cstr< N, T, view >::flatten ( const cstr< Sizes, value_type, view_type > &...  strs) const
inlineconstexprnoexcept

Flatten multiple strings of different lengths.

Note
Use the out-of-class flatten() function to better suit metaprogramming.
This method changes the string length, therefore it does not change *this, but returns the modified string.
Parameters
strsstrings to be flattened
Returns
Concatenated string.

◆ flatten() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<can_construct_cstr_t_from< value_type >... Strs>
constexpr auto conststr::cstr< N, T, view >::flatten ( const Strs &...  strs) const
inlineconstexprnoexcept

Flatten multiple strings of different lengths.

Note
Use the out-of-class flatten() function to better suit metaprogramming.
This method changes the string length, therefore it does not change *this, but returns the modified string.
Template Parameters
Strstypes of strings
Parameters
strsstrings to be flattened
Returns
Concatenated string.

◆ front() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_reference conststr::cstr< N, T, view >::front ( ) const
inlineconstexprnoexcept

Get the reference to the first character in the string.

Note
Reference to null terminator will be returned if string is empty.
Returns
Reference to the first character.

◆ front() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr reference conststr::cstr< N, T, view >::front ( )
inlineconstexprnoexcept

Get the reference to the first character in the string.

Note
Reference to null terminator will be returned if string is empty.
Returns
Reference to the first character.

◆ get() [1/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Idx>
requires (N > Idx)
constexpr rreference conststr::cstr< N, T, view >::get ( ) &&
inlineconstexprnoexcept

Tuple-like interface, extracts the Idx-th element from the string.

Template Parameters
Idxposition of the character
Returns
R-value reference to a character.

◆ get() [2/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Idx>
requires (N > Idx)
constexpr reference conststr::cstr< N, T, view >::get ( ) &
inlineconstexprnoexcept

Tuple-like interface, extracts the Idx-th element from the string.

Template Parameters
Idxposition of the character
Returns
Reference to a character.

◆ get() [3/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Idx>
requires (N > Idx)
constexpr const_rreference conststr::cstr< N, T, view >::get ( ) const &&
inlineconstexprnoexcept

Tuple-like interface, extracts the Idx-th element from the string.

Template Parameters
Idxposition of the character
Returns
R-value reference to a character.

◆ get() [4/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Idx>
requires (N > Idx)
constexpr const_reference conststr::cstr< N, T, view >::get ( ) const &
inlineconstexprnoexcept

Tuple-like interface, extracts the Idx-th element from the string.

Template Parameters
Idxposition of the character
Returns
Reference to a character.

◆ insert() [1/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<can_construct_cstr_t_from< value_type > Str>
constexpr auto conststr::cstr< N, T, view >::insert ( const_iterator  iter,
const Str &  str 
) const
inlineconstexprnoexcept

Insert another string before iterator iter.

Note
This method changes the string length, therefore it does not change *this, but returns the modified string.
Template Parameters
Strtype of another string
Parameters
iteriterator before which the characters will be inserted
strstring to insert
Returns
The modified string.

◆ insert() [2/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Count = 1>
constexpr auto conststr::cstr< N, T, view >::insert ( const_iterator  iter,
const value_type &  ch 
) const -> cstr<N + Count, value_type, view_type>
inlineconstexprnoexcept

Insert Count copies of character ch before iterator iter.

Note
This method changes the string length, therefore it does not change *this, but returns the modified string.
Template Parameters
Countcount of insertion, default to 1
Parameters
iteriterator before which the characters will be inserted
chcharacter to insert
Returns
The modified string.

◆ insert() [3/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<can_construct_cstr_t_from< value_type > Str>
constexpr auto conststr::cstr< N, T, view >::insert ( size_type  pos,
const Str &  str 
) const
inlineconstexprnoexcept

Insert another string at the position pos.

Note
This method changes the string length, therefore it does not change *this, but returns the modified string.
Template Parameters
Strtype of another string
Parameters
posposition that the characters will be inserted
strstring to insert
Returns
The modified string.

◆ insert() [4/4]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Count = 1>
constexpr auto conststr::cstr< N, T, view >::insert ( size_type  pos,
const value_type &  ch 
) const -> cstr<N + Count, value_type, view_type>
inlineconstexprnoexcept

Insert Count copies of character ch at the position pos.

Note
This method changes the string length, therefore it does not change *this, but returns the modified string.
Template Parameters
Countcount of insertion, default to 1
Parameters
posposition that the characters will be inserted
chcharacter to insert
Returns
The modified string.

◆ length()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
static constexpr size_type conststr::cstr< N, T, view >::length ( )
inlinestaticconstexprnoexcept

Alternative API of size(). Get size of string, without counting the null terminator.

Returns
The number of character element in the string.

◆ lowercase()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::lowercase ( ) const -> cstr<N, value_type, view_type>
inlineconstexprnoexcept

Convert all characters to lowercase. Always be equivalent to transform(charutils::tolower<value_type>).

Note
To maintain API uniformity, this method does not change *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>).
Returns
The modified string.

◆ max_size()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
static constexpr size_type conststr::cstr< N, T, view >::max_size ( )
inlinestaticconstexprnoexcept

Get the maximum number of characters the string is able to hold. Always the same as size().

Returns
Maximum number of characters.

◆ operator+()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<can_construct_cstr_t_from< value_type > Str>
constexpr auto conststr::cstr< N, T, view >::operator+ ( const Str &  str) const
inlineconstexprnoexcept

Concatenate the contents with another string.

Template Parameters
Strtype of another string
Parameters
stranother string to be concatenated
Returns
New string containing the concatenated contents of two strings.

◆ operator<=>() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<std::size_t N2, typename V2 >
constexpr auto conststr::cstr< N, T, view >::operator<=> ( const cstr< N2, value_type, V2 > &  other)
inlineconstexprnoexcept

Compares the contents of two strings lexicographically.

Note
Do not use s1 <=> s2 directly, this operator will automatically derive other logical operators: >, <, >= and <=.
Template Parameters
N2size of another string
V2view type of another string
Parameters
otheranother string to be compared
Returns
Ordering of two strings.

◆ operator<=>() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::operator<=> ( const view_type &  other) const
inlineconstexprnoexcept

Compares the contents of two strings lexicographically.

Note
Do not use s1 <=> s2 directly, this operator will automatically derive other logical operators: >, <, >= and <=.
Parameters
otheranother string to be compared
Returns
Ordering of two strings.

◆ operator==() [1/3]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<typename V2 >
constexpr bool conststr::cstr< N, T, view >::operator== ( const cstr< N, value_type, V2 > &  other) const
inlineconstexprnoexcept

Check if the contents of two strings are the same.

Template Parameters
V2view type of another string
Parameters
otheranother string to be compared
Returns
true if the contents of two strings are the same.
false otherwise.

◆ operator==() [2/3]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<std::size_t N2, typename V2 >
constexpr bool conststr::cstr< N, T, view >::operator== ( const cstr< N2, value_type, V2 > &  other) const
inlineconstexprnoexcept

Check if the contents of two strings are the same.

Template Parameters
N2size of another string
V2view type of another string
Parameters
otheranother string to be compared
Returns
false always in this overloaded version.

◆ operator==() [3/3]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr bool conststr::cstr< N, T, view >::operator== ( const view_type &  other) const
inlineconstexprnoexcept

Check if the contents of two strings are the same.

Parameters
otheranother string to be compared
Returns
true if the contents of two strings are the same.
false otherwise.

◆ operator[]() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_reference conststr::cstr< N, T, view >::operator[] ( size_type  pos) const
inlineconstexprnoexcept

Get the reference to the character at specified location pos.

Parameters
posposition of the character
Returns
Reference to a character.

◆ operator[]() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr reference conststr::cstr< N, T, view >::operator[] ( size_type  pos)
inlineconstexprnoexcept

Get the reference to the character at specified location pos.

Parameters
posposition of the character to return
Returns
Reference to a character.

◆ pop()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::pop ( ) const -> cstr<N - 1, value_type, view_type>
inlineconstexprnoexcept

Pop the last character from the end of string. Always be equivalent to cut<size() - 1>().

Note
This method changes the string length, therefore it does not change *this, but returns the modified string.
Returns
The modified string.

◆ push()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::push ( const value_type &  ch) const -> cstr<N + 1, value_type>
inlineconstexprnoexcept

Push a character to the end of string. Always be equivalent to append(ch).

Note
This method changes the string length, therefore it does not change *this, but returns the modified string.
Parameters
chcharacter to be pushed
Returns
The modified string.

◆ rbegin() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_reverse_iterator conststr::cstr< N, T, view >::rbegin ( ) const
inlineconstexprnoexcept

Get a reverse iterator to the first character of the reversed string.

Returns
Reverse iterator to the first character.

◆ rbegin() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr reverse_iterator conststr::cstr< N, T, view >::rbegin ( )
inlineconstexprnoexcept

Get a reverse iterator to the first character of the reversed string.

Returns
Reverse iterator to the first character.

◆ remove_prefix()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Len>
constexpr auto conststr::cstr< N, T, view >::remove_prefix ( ) const
inlineconstexprnoexcept

Remove Len bytes of prefix. Always be equivalent to substr<Len>().

Template Parameters
Lenbytes of prefix to remove
Returns
The substring [Len, size()).

◆ remove_suffix()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Len>
constexpr auto conststr::cstr< N, T, view >::remove_suffix ( ) const
inlineconstexprnoexcept

Remove Len bytes of suffix. Always be equivalent to substr<0, size() - Len>().

Template Parameters
Lenbytes of suffix to remove
Returns
The substring [0, size() - Len).

◆ rend() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr const_reverse_iterator conststr::cstr< N, T, view >::rend ( ) const
inlineconstexprnoexcept

Get a reverse iterator to the character following the last character of the reversed string.

Returns
Reverse iterator to the character following the last character.

◆ rend() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr reverse_iterator conststr::cstr< N, T, view >::rend ( )
inlineconstexprnoexcept

Get a reverse iterator to the character following the last character of the reversed string.

Returns
Reverse iterator to the character following the last character.

◆ replace() [1/6]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<value_type... Chs>
constexpr auto conststr::cstr< N, T, view >::replace ( const_iterator  first,
const_iterator  last 
) const -> cstr<N, value_type, view_type> requires(sizeof...(Chs) > 0)
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).

Note
To maintain API uniformity, this method does not change *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.
Template Parameters
Chscharacters for replacement, see the example
Parameters
firstbegin of range of characters that is going to be replaced
lastend of range of characters that is going to be replaced
Returns
The modified string.

◆ replace() [2/6]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::replace ( const_iterator  first,
const_iterator  last,
const value_type &  ch 
) const -> cstr<N, value_type, view_type>
inlineconstexprnoexcept

Replaces the characters in the range [max(first, cbegin()), min(last, cend())) with character ch.

Note
To maintain API uniformity, this method does not change *this, but returns the modified string. If you really want to modify current string, use ‘std::transform(first, last, first, charutils::just<'a’>)whilefirstand last` are iterators of current string.
Parameters
firstbegin of range of characters that is going to be replaced
lastend of range of characters that is going to be replaced
chcharacter value to use for replacement
Returns
The modified string.

◆ replace() [3/6]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::replace ( const_iterator  first,
const_iterator  last,
const view_type &  str 
) const -> cstr<N, value_type, view_type>
inlineconstexprnoexcept

Replaces the characters in the range [max(first, cbegin()), min(last, cend())) with another string str.

Note
To maintain API uniformity, this method does not change *this, but returns the modified string.
Parameters
firstbegin of range of characters that is going to be replaced
lastend of range of characters that is going to be replaced
strstring to use for replacement
Returns
The modified string.

◆ replace() [4/6]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::replace ( size_type  pos,
const value_type &  ch,
size_type  count = 1 
) const -> cstr<N, value_type, view_type>
inlineconstexprnoexcept

Replaces the characters in the range [pos, min(pos + count, size())) with character ch.

Note
To maintain API uniformity, this method does not change *this, but returns the modified string. If you really want to modify current string, use ‘std::transform(first, last, first, charutils::just<'a’>)whilefirstand last` are iterators of current string.
Parameters
posstart of the substring that is going to be replaced
chcharacter value to use for replacement
countlength of the substring that is going to be replaced
Returns
The modified string.

◆ replace() [5/6]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::replace ( size_type  pos,
const view_type &  str,
size_type  count = 1 
) const -> cstr<N, value_type, view_type>
inlineconstexprnoexcept

Replaces the characters in the range [pos, min(pos + str.size() * count, size())) with another string str.

Note
To maintain API uniformity, this method does not change *this, but returns the modified string.
Parameters
posstart of the substring that is going to be replaced
strstring to use for replacement
countreplacement times of str
Returns
The modified string.

◆ replace() [6/6]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<value_type... Chs>
constexpr auto conststr::cstr< N, T, view >::replace ( size_type  pos = 0,
size_type  len = N 
) const -> cstr<N, value_type, view_type> requires(sizeof...(Chs) > 0)
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).

Note
To maintain API uniformity, this method does not change *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.
Template Parameters
Chscharacters for replacement, see the example
Parameters
posstart of the substring that is going to be replaced
lenlength of the substring that is going to be replaced
Returns
The modified string.

◆ rfind() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr size_type conststr::cstr< N, T, view >::rfind ( const value_type &  ch,
size_type  pos = npos 
) const
inlineconstexprnoexcept

Find the last character equal to the given character.

Parameters
chcharacter to search for
posposition at which to start the search
Returns
Position of the found character or npos if not found.

◆ rfind() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr size_type conststr::cstr< N, T, view >::rfind ( const view_type &  str,
size_type  pos = npos 
) const
inlineconstexprnoexcept

Find the last substring equal to the given substring.

Parameters
strsubstring to search for
posposition at which to start the search
Returns
Position of the first character of the found substring or npos if not found.

◆ rfind_if()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<typename UnaryPredicate >
constexpr size_type conststr::cstr< N, T, view >::rfind_if ( UnaryPredicate  p,
size_type  pos = npos 
) const
inlineconstexprnoexcept

Find the last character for which predicate p returns true.

Template Parameters
UnaryPredicatetype of the unary predicate function
Parameters
punary predicate function object which returns true for the required element.
posposition at which to start the search
Returns
Position of the found character or npos if not found.

◆ size()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
static constexpr size_type conststr::cstr< N, T, view >::size ( )
inlinestaticconstexprnoexcept

Get size of string, without counting the null terminator.

Returns
The number of character element in the string.

◆ starts_with() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr bool conststr::cstr< N, T, view >::starts_with ( const value_type &  ch) const
inlineconstexprnoexcept

Check if the string begins with the given character.

Parameters
chany character
Returns
true if the string begins with the provided character.
false otherwise.

◆ starts_with() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr bool conststr::cstr< N, T, view >::starts_with ( const view_type &  str) const
inlineconstexprnoexcept

Check if the string begins with the given substring.

Parameters
strany string
Returns
true if the string begins with the provided substring.
false otherwise.

◆ substr()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<size_type Start, size_type Len = N>
requires (N >= Start)
constexpr auto conststr::cstr< N, T, view >::substr ( ) const
inlineconstexprnoexcept

Get the substring.

Template Parameters
Startposition of the first character
Lenlength of the substring
Returns
The substring [Start, Start + Len) or [Start, size()).

◆ swap()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<typename V2 >
constexpr void conststr::cstr< N, T, view >::swap ( cstr< N, value_type, V2 > &  other)
inlineconstexprnoexcept

Swap the contents of this string with another string.

Template Parameters
V2view type of another string
Parameters
otheranother string to swap the contents

◆ transform() [1/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<typename UnaryOperation , typename V2 = void>
requires (meta::viewer<V2, operation_result<UnaryOperation>> || (std::is_void_v<V2>))
constexpr auto conststr::cstr< N, T, view >::transform ( UnaryOperation  op,
const_iterator  first,
const_iterator  last,
const sv_selector< V2 > &  svs = {} 
) const
inlineconstexprnoexcept

Apply the given function to each character in the range [first, min(last, cend())).

Note
To maintain API uniformity, this method does not change *this, but returns the modified string. If you really want to modify current string, use std::transform(str.begin(), str.end(), str.begin(), op).
Template Parameters
UnaryOperationtype of the unary operation function
V2view 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>
Parameters
opunary operation function object that will be applied, the signature of the function should be Ret f(const T &) or Ret f(T).
firstiterator to the start position of the range
lastiterator to the end position of the range
svsstring view type selector
Returns
The generated string.
See also
sv

◆ transform() [2/2]

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<typename UnaryOperation , typename V2 = void>
requires (meta::viewer<V2, operation_result<UnaryOperation>> || (std::is_void_v<V2>))
constexpr auto conststr::cstr< N, T, view >::transform ( UnaryOperation  op,
size_type  pos = 0,
size_type  len = N,
const sv_selector< V2 > &  svs = {} 
) const
inlineconstexprnoexcept

Apply the given function to each character in the range [pos, min(pos + len, size())).

Note
To maintain API uniformity, this method does not change *this, but returns the modified string. If you really want to modify current string, use std::transform(str.begin(), str.end(), str.begin(), op).
Template Parameters
UnaryOperationtype of the unary operation function
Vview 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>
Parameters
opunary operation function object that will be applied, the signature of the function should be Ret f(const T &) or Ret f(T).
posstart position of the range
lencount of character to be handled
svsstring view type selector
Returns
The generated string.
See also
sv

◆ uppercase()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
constexpr auto conststr::cstr< N, T, view >::uppercase ( ) const -> cstr<N, value_type, view_type>
inlineconstexprnoexcept

Convert all characters to uppercase. Always be equivalent to transform(charutils::toupper<value_type>).

Note
To maintain API uniformity, this method does not change *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>).
Returns
The modified string.

◆ with_view()

template<std::size_t N, charutils::char_like T = char, typename view = std::basic_string_view<T>>
template<meta::viewer< value_type, size_type > V2>
constexpr auto conststr::cstr< N, T, view >::with_view ( ) const -> cstr<N, value_type, V2>
inlineconstexprnoexcept

Change view type.

Template Parameters
V2new view type
Returns
String with new view type

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