| Home | Libraries | People | FAQ | More

#### static_string

A modifiable string with a fixed-size storage area.

##### Synopsis

Defined in header `<boost/beast/core/static_string.hpp>`

    template<
        std::size_t N,
        class CharT = char,
        class Traits = std::char_traits<CharT>>
    class static_string

##### Types

Name | Description
--- | ---
const_iterator |
const_pointer |
const_reference |
const_reverse_iterator |
difference_type |
iterator |
pointer |
reference |
reverse_iterator |
size_type |
string_view_type | The type of string_view returned by the interface.
traits_type |
value_type |

##### Member Functions

Name | Description
--- | ---
append |
assign | Assign count copies of ch. Assign from another static_string Assign count characterss starting at npos from other. Assign the first count characters of s, including nulls. Assign a null terminated string. Assign from an iterator range of characters. Assign from any object convertible to string_view_type.
at | Access specified character with bounds checking.
back | Accesses the last character.
begin | Returns an iterator to the beginning.
c_str | Returns a non-modifiable standard C character array version of the string.
capacity | Returns the number of characters that can be held in currently allocated storage.
cbegin | Returns an iterator to the beginning.
cend | Returns an iterator to the end.
clear | Clears the contents.
compare |
copy | Copy a substring (pos, pos+count) to character string pointed to by dest.
crbegin | Returns a reverse iterator to the beginning.
crend | Returns a reverse iterator to the end.
data | Returns a pointer to the first character of a string.
empty | Returns true if the string is empty.
end | Returns an iterator to the end.
erase |
front | Accesses the first character.
insert |
length | Returns the number of characters, excluding the null terminator.
max_size | Returns the maximum number of characters that can be stored, excluding the null terminator.
operator string_view_type | Convert a static string to a string_view_type
operator+= |
operator= | Copy assignment. Assign from null-terminated string. Assign from single character. Assign from initializer list. Assign from string_view_type.
operator[] | Access specified character.
pop_back |
push_back |
rbegin | Returns a reverse iterator to the beginning.
rend | Returns a reverse iterator to the end.
reserve | Reserves storage.
resize | Changes the number of characters stored.
shrink_to_fit | Reduces memory usage by freeing unused memory.
size | Returns the number of characters, excluding the null terminator.

static_string

Default constructor (empty string).

Construct with count copies of character ch.

Construct with a substring (pos, other.size()) of other.

Construct with a substring (pos, count) of other.

Construct with the first count characters of s, including nulls.

Construct from a null terminated string.

Construct from a range of characters.

Copy constructor.

Construct from an initializer list.

Construct from a string_view

Construct from any object convertible to string_view_type.

substr |
swap | Exchange the contents of this string with another.

##### Data Members

Name | Description
--- | ---
max_size_n | Maximum size of the string excluding the null terminator.
npos | A special index.

##### Description

These objects behave like `std::string` except that the storage is not dynamically allocated but rather fixed in size. These strings offer performance advantages when a protocol imposes a natural small upper limit on the size of a value.

##### Remarks

The stored string is always null-terminated.

##### See Also

`to_static_string`

Convenience header `<boost/beast/core.hpp>`