...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A fixed-capacity string.
Defined in header <boost/static_string/static_string.hpp>
template< std::size_t N, typename CharT, typename Traits = std::char_traits<CharT>> class basic_static_string
Name |
Description |
---|---|
The constant iterator type. |
|
The constant pointer type. |
|
The constant reference type. |
|
The constant reverse iterator type. |
|
The difference type. |
|
The iterator type. |
|
The pointer type. |
|
The reference type. |
|
The reverse iterator type. |
|
The size type. |
|
The string view type. |
|
The traits type. |
|
The character type. |
Name |
Description |
---|---|
Append to the string. |
|
Assign to the string. |
|
Access a character with bounds checking. |
|
Return the last character. |
|
basic_static_string [constructor] |
Constructor. |
Return an iterator to the beginning. |
|
Return a pointer to the string. |
|
Return the number of characters that can be stored. |
|
Return an iterator to the beginning. |
|
Return an iterator to the end. |
|
Clear the contents. |
|
Compare a string with the string. |
|
Copy a substring to another string. |
|
Return a reverse iterator to the beginning. |
|
Return a reverse iterator to the end. |
|
Return a pointer to the string. |
|
Return if the string is empty. |
|
Return an iterator to the end. |
|
Return whether the string ends with a string. |
|
Erase from the string. |
|
Find the first occurrence of a string within the string. |
|
Find the first occurrence of a character not within the string.
|
|
Find the first occurrence of any of the characters within the string.
|
|
Find the last occurrence of a character not within the string.
|
|
Find the last occurrence of any of the characters within the string.
|
|
Return the first character. |
|
Insert into the string. |
|
Return the size of the string. |
|
Return the number of characters that can be stored. |
|
Convert to a string view referring to the string. |
|
Append to the string. |
|
Assign to the string. |
|
Access a character. |
|
Remove the last character. |
|
Append a character. |
|
Return a reverse iterator to the beginning. |
|
Return a reverse iterator to the end. |
|
Replace a part of the string. |
|
Increase the capacity. |
|
Change the size of the string. |
|
Find the last occurrence of a string within the string. |
|
Request the removal of unused capacity. |
|
Return the size of the string. |
|
Return whether the string begins with a string. |
|
Return a substring. |
|
Return a string view of a substring. |
|
Swap two strings. |
Name |
Description |
---|---|
A special index. |
|
Maximum size of the string excluding any null terminator. |
These objects behave like std::string
except that the storage is not dynamically allocated but rather fixed in
size, and stored in the object itself. These strings offer performance advantages
when an algorithm can execute with a reasonable upper limit on the size of
a value.
The following alias templates are provided for convenience:
template<std::size_t N> using static_string = basic_static_string<N, char, std::char_traits<char>>;
template<std::size_t N> using static_wstring = basic_static_string<N, wchar_t, std::char_traits<wchar_t>>;
template<std::size_t N> using static_u16string = basic_static_string<N, char16_t, std::char_traits<char16_t>>;
template<std::size_t N> using static_u32string = basic_static_string<N, char32_t, std::char_traits<char32_t>>;
Addtionally, the alias template static_u8string
is provided in C++20
template<std::size_t N> using static_u8string = basic_static_string<N, char8_t, std::char_traits<char8_t>>;
to_static_string