|
gw
1.0.0
A bunch of small C++ utilities
|
A fixed-size string that stores the data in-place. More...
#include <inplace_string.hpp>
Public Types | |
| using | traits_type = Traits |
| The character traits type. | |
| using | value_type = CharT |
| The character type. | |
| using | size_type = std::size_t |
| The size type. | |
| using | difference_type = std::ptrdiff_t |
| The difference type. | |
| using | reference = value_type & |
| The reference type. | |
| using | const_reference = const value_type & |
| The const reference type. | |
| using | pointer = value_type * |
| The pointer type. | |
| using | const_pointer = const value_type * |
| The const pointer type. | |
| using | iterator = value_type * |
| The iterator type. | |
| using | const_iterator = const value_type * |
| The const iterator type. | |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| The reverse iterator type. | |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| The const reverse iterator type. | |
Public Member Functions | |
| constexpr | basic_inplace_string () noexcept=default |
| Default constructor. | |
|
template<std::size_t N2> requires (N2 <= N + 1) | |
| consteval | explicit (false) basic_inplace_string(const value_type(&str)[N2]) noexcept |
Construct the string with the characters from the character string pointed to by str. | |
| constexpr | basic_inplace_string (size_type count, value_type ch) |
Construct the string with count copies of character ch. | |
| constexpr | basic_inplace_string (const value_type *str) |
Construct the string with the characters from the character string pointed to by str. | |
| constexpr | basic_inplace_string (const value_type *str, size_type count) |
| Construct the string with the contents of the range [str, str + count). | |
| template<std::input_iterator InputIt> | |
| constexpr | basic_inplace_string (InputIt first, InputIt last) |
| Construct the string with the contents of the range [first, last). | |
| constexpr | basic_inplace_string (const std::basic_string_view< value_type, traits_type > &str) |
| Construct the string with the contents of the string view. | |
| template<std::ranges::range R> requires (!std::is_convertible_v<const R&, std::basic_string_view<value_type, traits_type>> && std::convertible_to<std::ranges::range_value_t<R>, value_type>) | |
| constexpr | basic_inplace_string (const R &range) |
| Construct the string with the contents of the range. | |
| constexpr | basic_inplace_string (const basic_inplace_string &other) noexcept=default |
| Copy constructor. | |
| constexpr | basic_inplace_string (basic_inplace_string &&other) noexcept=default |
| Move constructor. | |
| constexpr | ~basic_inplace_string () noexcept=default |
| Destructor. | |
| constexpr auto | operator= (const basic_inplace_string &other) noexcept -> basic_inplace_string &=default |
| Copy assignment operator. | |
| constexpr auto | operator= (basic_inplace_string &&other) noexcept -> basic_inplace_string &=default |
| Move assignment operator. | |
| constexpr auto | at (size_type pos) -> reference |
| Get a reference to the character at the specified position. | |
| constexpr auto | at (size_type pos) const -> const_reference |
| Get a const reference to the character at the specified position. | |
| constexpr auto | operator[] (size_type pos) noexcept -> reference |
| Get a reference to the character at the specified position. | |
| constexpr auto | operator[] (size_type pos) const noexcept -> const_reference |
| Get a const reference to the character at the specified position. | |
| constexpr auto | front () noexcept -> reference |
| Get a reference to the first character in the string. | |
| constexpr auto | front () const noexcept -> const_reference |
| Get a const reference to the first character in the string. | |
| constexpr auto | back () noexcept -> reference |
| Get a reference to the last character in the string. | |
| constexpr auto | back () const noexcept -> const_reference |
| Get a const reference to the last character in the string. | |
| constexpr auto | data () noexcept -> pointer |
| Get a pointer to the underlying character array. | |
| constexpr auto | data () const noexcept -> const_pointer |
| Get a const pointer to the underlying character array. | |
| constexpr auto | c_str () const noexcept -> const_pointer |
| Get a const pointer to the underlying character array. | |
| constexpr | operator std::basic_string_view< value_type, traits_type > () const noexcept |
| Get a string view of the string. | |
| constexpr auto | view () const noexcept -> std::basic_string_view< value_type, traits_type > |
| Get a string view of the string. | |
| constexpr auto | begin () noexcept -> iterator |
| Get an iterator to the beginning of the string. | |
| constexpr auto | begin () const noexcept -> const_iterator |
| Get a const iterator to the beginning of the string. | |
| constexpr auto | cbegin () const noexcept -> const_iterator |
| Get a const iterator to the beginning of the string. | |
| constexpr auto | end () noexcept -> iterator |
| Get an iterator to the end of the string. | |
| constexpr auto | end () const noexcept -> const_iterator |
| Get a const iterator to the end of the string. | |
| constexpr auto | cend () const noexcept -> const_iterator |
| Get a const iterator to the end of the string. | |
| constexpr auto | rbegin () noexcept -> reverse_iterator |
| Get a reverse iterator to the end of the string. | |
| constexpr auto | rbegin () const noexcept -> const_reverse_iterator |
| Get a const reverse iterator to the end of the string. | |
| constexpr auto | crbegin () const noexcept -> const_reverse_iterator |
| Get a const reverse iterator to the end of the string. | |
| constexpr auto | rend () noexcept -> reverse_iterator |
| Get a reverse iterator to the beginning of the string. | |
| constexpr auto | rend () const noexcept -> const_reverse_iterator |
| Get a const reverse iterator to the beginning of the string. | |
| constexpr auto | crend () const noexcept -> const_reverse_iterator |
| Get a const reverse iterator to the beginning of the string. | |
| constexpr auto | empty () const noexcept -> bool |
| Check if the string is empty. | |
| constexpr auto | size () const noexcept -> size_type |
| Get the size of the string. | |
| constexpr auto | length () const noexcept -> size_type |
| Get the length of the string. | |
| constexpr auto | max_size () const noexcept -> size_type |
| Get the maximum size of the string. | |
| constexpr void | reserve (size_type new_cap) |
| Reserve storage for the string. | |
| constexpr auto | capacity () const noexcept -> size_type |
| Get the capacity of the string. | |
| constexpr void | shrink_to_fit () |
| Shrink the capacity of the string to fit its size. | |
| constexpr void | clear () noexcept |
| Clear the contents of the string. | |
| constexpr void | insert (size_type index, size_type count, CharT ch) |
Insert count copies of character ch at the position index. | |
| auto | insert (size_type index, const value_type *str) -> basic_inplace_string & |
Insert the null-terminated character string pointed to by str at the position index. | |
| auto | insert (size_type index, const value_type *str, size_type count) -> basic_inplace_string & |
Insert the characters in the range [str, str + count) at the position index. | |
| template<std::size_t N2> | |
| auto | insert (size_type index, const basic_inplace_string< N2, value_type, traits_type > &str) -> basic_inplace_string & |
Insert the inplace string at the position index. | |
| auto | insert (const_iterator pos, value_type ch) -> iterator |
Insert the character ch before the element (if any) pointed by pos. | |
| auto | insert (const_iterator pos, size_type count, value_type ch) -> iterator |
Insert count copies of character ch before the element (if any) pointed by pos. | |
| template<std::input_iterator InputIt> requires std::convertible_to<std::iter_value_t<InputIt>, value_type> | |
| auto | insert (const_iterator pos, InputIt first, InputIt last) -> iterator |
Insert the characters from the range [first, last) before the element (if any) pointed by pos. | |
| template<std::ranges::input_range R> requires std::convertible_to<std::ranges::range_value_t<R>, value_type> | |
| constexpr auto | insert_range (const_iterator pos, R &&range) -> iterator |
Insert the characters from the range before the element (if any) pointed by pos. | |
| constexpr void | erase (size_type index=0U, size_type count=npos) |
Erase count characters from the position index. | |
| constexpr void | push_back (value_type ch) |
| Append a character to the end of the string. | |
| constexpr void | pop_back () noexcept |
| Remove the last character from the string. | |
| template<std::size_t N2> | |
| constexpr void | append (const basic_inplace_string< N2, value_type, traits_type > &str) |
| Append a string to the end of the string. | |
| constexpr void | resize (size_type count) |
Resize the string to count characters. | |
| constexpr void | resize (size_type count, value_type ch) |
Resize the string to count characters. | |
| constexpr void | swap (basic_inplace_string &other) noexcept |
| Swap the string with another string. | |
| template<std::size_t N2> | |
| constexpr auto | find (const basic_inplace_string< N2, value_type, traits_type > &str, size_type pos=0) const noexcept -> size_type |
Find the first substring equal to str. | |
| constexpr auto | find (std::basic_string_view< value_type, traits_type > str, size_type pos=0) const noexcept -> size_type |
Find the first substring equal to str. | |
| constexpr auto | find (const value_type *str, size_type pos, size_type count) const noexcept -> size_type |
Find the first substring equal to the range [str, str + count). | |
| constexpr auto | find (const value_type *str, size_type pos=0) const noexcept -> size_type |
Find the first substring equal to the character string pointed to by str. | |
| constexpr auto | find (value_type ch, size_type pos=0) const noexcept -> size_type |
Find the first character ch. | |
| template<std::size_t N2> | |
| constexpr auto | rfind (const basic_inplace_string< N2, value_type, traits_type > &str, size_type pos=npos) const noexcept -> size_type |
Find the last substring equal to str. | |
| constexpr auto | rfind (std::basic_string_view< value_type, traits_type > str, size_type pos=npos) const noexcept -> size_type |
Find the last substring equal to str. | |
| constexpr auto | rfind (const value_type *str, size_type pos, size_type count) const noexcept -> size_type |
Find the last substring equal to the range [str, str + count). | |
| constexpr auto | rfind (const value_type *str, size_type pos=npos) const noexcept -> size_type |
Find the last substring equal to the character string pointed to by str. | |
| constexpr auto | rfind (value_type ch, size_type pos=npos) const noexcept -> size_type |
Find the last character ch. | |
| template<std::size_t N2> | |
| constexpr auto | find_first_of (const basic_inplace_string< N2, value_type, traits_type > &str, size_type pos=0) const noexcept -> size_type |
Find the first character equal to one of the characters in str. | |
| constexpr auto | find_first_of (std::basic_string_view< value_type, traits_type > str, size_type pos=0) const noexcept -> size_type |
Find the first character equal to one of the characters in str. | |
| constexpr auto | find_first_of (const value_type *str, size_type pos=0) const noexcept -> size_type |
Find the first character equal to one of the characters in str. | |
Public Attributes | |
| std::array< value_type, N+1U > | m_data |
| The character array. | |
Static Public Attributes | |
| static constexpr size_type | npos = -1 |
| The maximum value for size_type. | |
A fixed-size string that stores the data in-place.
| N | The size of the string. |
| CharT | The character type. |
| Traits | The character traits type. |
|
inlineconstexpr |
Construct the string with count copies of character ch.
| count | The number of characters to initialize the string with. |
| ch | The character to initialize the string with. |
| std::length_error | If count is greater than max_size. |
|
inlineexplicitconstexpr |
Construct the string with the characters from the character string pointed to by str.
| str | The character string to initialize the string with. |
| std::length_error | If the size of str would exceed max_size. |
|
inlineexplicitconstexpr |
Construct the string with the contents of the range [str, str + count).
| str | The beginning of the range. |
| count | The number of characters to initialize the string with. |
| std::length_error | If count is greater than max_size. |
|
inlineexplicitconstexpr |
Construct the string with the contents of the range [first, last).
| InputIt | The type of the iterators. |
| first | The beginning of the range. |
| last | The end of the range. |
| std::length_error | If the size of the range would exceed max_size. |
|
inlineexplicitconstexpr |
Construct the string with the contents of the string view.
| str | The string view to initialize the string with. |
| std::length_error | If the size of the string view would exceed max_size. |
|
inlineexplicitconstexpr |
Construct the string with the contents of the range.
| R | The type of the range. |
| range | The range to initialize the string with. |
|
inlineconstexpr |
Append a string to the end of the string.
| N2 | The size of the string. |
| str | The string to append. |
| std::length_error | If the size of the string would exceed max_size. |
|
inlineconstexpr |
Get a reference to the character at the specified position.
| pos | The position of the character to get. |
| std::out_of_range | If pos is out of range. |
|
inlineconstexpr |
Get a const reference to the character at the specified position.
| pos | The position of the character to get. |
| std::out_of_range | If pos is out of range. |
|
inlineconstexprnoexcept |
Get a const reference to the last character in the string.
|
inlineconstexprnoexcept |
Get a reference to the last character in the string.
|
inlineconstexprnoexcept |
Get a const iterator to the beginning of the string.
|
inlineconstexprnoexcept |
Get an iterator to the beginning of the string.
|
inlineconstexprnoexcept |
Get a const pointer to the underlying character array.
|
inlineconstexprnoexcept |
Get the capacity of the string.
|
inlineconstexprnoexcept |
Get a const iterator to the beginning of the string.
|
inlineconstexprnoexcept |
Get a const iterator to the end of the string.
|
inlineconstexprnoexcept |
Get a const reverse iterator to the end of the string.
|
inlineconstexprnoexcept |
Get a const reverse iterator to the beginning of the string.
|
inlineconstexprnoexcept |
Get a const pointer to the underlying character array.
|
inlineconstexprnoexcept |
Get a pointer to the underlying character array.
|
inlineconstexprnoexcept |
Check if the string is empty.
|
inlineconstexprnoexcept |
Get a const iterator to the end of the string.
|
inlineconstexprnoexcept |
Get an iterator to the end of the string.
|
inlineconstexpr |
Erase count characters from the position index.
| index | The position to erase the characters from. |
| count | The number of characters to erase. |
| std::out_of_range | If index is greater than or equal to the size of the string. |
|
inlineconstexprnoexcept |
Find the first substring equal to str.
| N2 | The size of the string. |
| str | The string to find. |
| pos | The position to start searching from. |
npos if the string is not found.
|
inlineconstexprnoexcept |
Find the first substring equal to the range [str, str + count).
| str | The string to find. |
| pos | The position to start searching from. |
| count | The number of characters to search for. |
npos if the string is not found.
|
inlineconstexprnoexcept |
Find the first substring equal to the character string pointed to by str.
| str | The string to find. |
| pos | The position to start searching from. |
npos if the string is not found.
|
inlineconstexprnoexcept |
Find the first substring equal to str.
| str | The string view to find. |
| pos | The position to start searching from. |
npos if the string is not found.
|
inlineconstexprnoexcept |
Find the first character ch.
| ch | The character to find. |
| pos | The position to start searching from. |
npos if the character is not found.
|
inlineconstexprnoexcept |
Find the first character equal to one of the characters in str.
| N2 | The size of the string. |
| str | The string to search for. |
| pos | The position to start searching from. |
npos if no character is found.
|
inlineconstexprnoexcept |
Find the first character equal to one of the characters in str.
| str | The character string to search for. |
| pos | The position to start searching from. |
npos if no character is found.
|
inlineconstexprnoexcept |
Find the first character equal to one of the characters in str.
| str | The string view to search for. |
| pos | The position to start searching from. |
npos if no character is found.
|
inlineconstexprnoexcept |
Get a const reference to the first character in the string.
|
inlineconstexprnoexcept |
Get a reference to the first character in the string.
|
inline |
Insert the characters from the range [first, last) before the element (if any) pointed by pos.
| InputIt | The type of the iterators. |
| pos | The position to insert the characters before. |
| first | The beginning of the range. |
| last | The end of the range. |
pos if no characters were inserted. | std::length_error | If the size of the string would exceed max_size. |
|
inline |
Insert count copies of character ch before the element (if any) pointed by pos.
| pos | The position to insert the characters before. |
| count | The number of characters to insert. |
| ch | The character to insert. |
|
inline |
Insert the character ch before the element (if any) pointed by pos.
| pos | The position to insert the characters before. |
| ch | The character to insert. |
|
inline |
Insert the inplace string at the position index.
| N2 | The size of the string. |
| index | The position to insert the characters at. |
| str | The string to insert. |
| std::length_error | If the size of the string would exceed max_size. |
|
inline |
Insert the null-terminated character string pointed to by str at the position index.
| index | The position to insert the characters at. |
| str | The character string to insert. |
| std::length_error | If the size of the string would exceed max_size. |
|
inline |
Insert the characters in the range [str, str + count) at the position index.
| index | The position to insert the characters at. |
| str | The character string to insert. |
| count | The number of characters to insert. |
| std::length_error | If the size of the string would exceed max_size. |
|
inlineconstexpr |
Insert count copies of character ch at the position index.
| index | The position to insert the characters at. |
| count | The number of characters to insert. |
| ch | The character to insert. |
| std::length_error | If the size of the string would exceed max_size. |
|
inlineconstexpr |
Insert the characters from the range before the element (if any) pointed by pos.
| R | The type of the range. |
| pos | The position to insert the characters before. |
| range | The range to insert. |
pos if no characters were inserted. | std::length_error | If the size of the string would exceed max_size. |
|
inlineconstexprnoexcept |
Get the length of the string.
|
inlineconstexprnoexcept |
Get the maximum size of the string.
|
inlineexplicitconstexprnoexcept |
Get a string view of the string.
|
inlineconstexprnoexcept |
Get a const reference to the character at the specified position.
| pos | The position of the character to get. |
|
inlineconstexprnoexcept |
Get a reference to the character at the specified position.
| pos | The position of the character to get. |
|
inlineconstexpr |
Append a character to the end of the string.
| ch | The character to append. |
| std::length_error | If the size of the string would exceed max_size. |
|
inlineconstexprnoexcept |
Get a const reverse iterator to the end of the string.
|
inlineconstexprnoexcept |
Get a reverse iterator to the end of the string.
|
inlineconstexprnoexcept |
Get a const reverse iterator to the beginning of the string.
|
inlineconstexprnoexcept |
Get a reverse iterator to the beginning of the string.
|
inlineconstexpr |
Reserve storage for the string.
| new_cap | The new capacity of the string. |
| std::length_error | If new_cap is greater than max_size. |
|
inlineconstexpr |
Resize the string to count characters.
| count | The new size of the string. |
| std::length_error | If count is greater than max_size. |
|
inlineconstexpr |
Resize the string to count characters.
| count | The new size of the string. |
| ch | The character to fill the string with. |
| std::length_error | If count is greater than max_size. |
|
inlineconstexprnoexcept |
Find the last substring equal to str.
| N2 | The size of the string. |
| str | The string to find. |
| pos | The position to start searching from. |
npos if the string is not found.
|
inlineconstexprnoexcept |
Find the last substring equal to the range [str, str + count).
| str | The string to find. |
| pos | The position to start searching from. |
| count | The number of characters to search for. |
npos if the string is not found.
|
inlineconstexprnoexcept |
Find the last substring equal to the character string pointed to by str.
| str | The string to find. |
| pos | The position to start searching from. |
npos if the string is not found.
|
inlineconstexprnoexcept |
Find the last substring equal to str.
| str | The string to find. |
| pos | The position to start searching from. |
npos if the string is not found.
|
inlineconstexprnoexcept |
Find the last character ch.
| ch | The character to find. |
| pos | The position to start searching from. |
npos if the character is not found. Shrink the capacity of the string to fit its size.
|
inlineconstexprnoexcept |
Get the size of the string.
|
inlineconstexprnoexcept |
Swap the string with another string.
| other | The string to swap with. |
|
inlineconstexprnoexcept |
Get a string view of the string.
|
friend |
Concatenate two strings.
| N2 | The size of the second string. |
| lhs | The first string to concatenate. |
| rhs | The second string to concatenate. |
|
friend |
Write the string to an output stream.
| ostream | The output stream to write to. |
| rhs | The string to write. |
|
friend |
Compare the string to another string.
| lhs | The first string to compare. |
| rhs | The second string to compare. |
|
friend |
Compares the string to a character string.
| lhs | The first string to compare. |
| rhs | The second string to compare. |
|
friend |
Compare the string to a string view.
| lhs | The first string to compare. |
| rhs | The second string to compare. |
|
friend |
Compares the string to a character string.
| lhs | The first string to compare. |
| rhs | The second string to compare. |
|
friend |
Compare the string to a string view.
| lhs | The first string to compare. |
| rhs | The second string to compare. |
|
friend |
Read the string from an input stream.
| istream | The input stream to read from. |
| rhs | The string to read into. |
| std::array<value_type, N + 1U> gw::basic_inplace_string< N, CharT, Traits >::m_data |
The character array.
basic_inplace_string as a non-type template parameter.