Class template basic_fixed_string
<fixed_string.hpp>
#
Defined in header template< typename TChar, std::size_t N, typename TTraits = std::char_traits<TChar>> struct basic_fixed_string;
The class template basic_fixed_string
describes objects that can store a sequence consisting of a fixed number of arbitrary char
-like objects with the first element of the sequence at position zero.
Several typedefs for common character types are provided:
Type | Definition | |
---|---|---|
fixstr::fixed_string<N> | fixstr::basic_fixed_string<char, N> | |
fixstr::fixed_u8string<N> | fixstr::basic_fixed_string<char8_t, N> | since C++20 |
fixstr::fixed_u16string<N> | fixstr::basic_fixed_string<char16_t, N> | |
fixstr::fixed_u32string<N> | fixstr::basic_fixed_string<char32_t, N> | |
fixstr::fixed_wstring<N> | fixstr::basic_fixed_string<wchar_t, N> |
NOTE
In actual implementation, these are not the type aliases. Unfortunately, early GCC versions that are supported cNTTP couldn't automatically deduct size_t
template parameter when an alias was used in cNTTP. So, the actual implementation is that every "typedef" is actually a separate class inherited from basic_fixed_string
.
#
Template parametersName | Description |
---|---|
TChar | character type |
N | string size |
TTraits | CharTraits class specifying the operations on the character type. Like for std::basic_string or std::basic_string_view , TTraits::char_type must name the same type as TChar or the program is ill-formed. |
#
Member typesMember type | Definiton |
---|---|
traits_type | TTraits |
value_type | TChar |
pointer | value_type* |
const_pointer | const value_type* |
reference | value_type& |
iterator | LegacyRandomAccessIterator to value_type |
const_iterator | Constant LegacyRandomAccessIterator to value_type |
reverse_iterator | std::reverse_iterator<iterator> |
const_reverse_iterator | std::reverse_iterator<const_iterator> |
size_type | size_t |
difference_type | ptrdiff_t |
string_view_type | std::basic_string_view<value_type, traits_type> |
#
Member functions#
Constructors and assignmentName | Description |
---|---|
(constructor) | Constructs a basic_fixed_string |
operator= | assigns values to the string |
#
Element accessName | Description |
---|---|
operator[] | access specified element |
at | access specified element with bounds checking |
front | accesses the first character |
back | accesses the last character |
data | returns a pointer to the first character of a string |
c_str | returns a non-modifiable standard C character array version of the string |
#
IteratorsName | Description |
---|---|
begin cbegin | returns an iterator to the beginning |
end cend | returns an iterator to the end |
rbegin crbegin | returns a reverse iterator to the beginning |
rend crend | returns a reverse iterator to the end |
#
CapacityName | Description |
---|---|
empty | checks whether the fixed string is empty |
size length | returns the number of characters |
max_size | returns the maximum number of characters |
#
OperationsName | Description |
---|---|
substr | returns a substring |
find | find characters in the fixed string |