Encapsulates a fixed-size character buffer. The character type and the buffer's length are templated. Furthermore the buffer, and with it this type, is aligned to 8
bytes on 64-bit machines and to 4
bytes on 32-bit hardware. This supports fast access and compile-time optimizations.
An overloaded constructor and method Fill allow filling the buffer with a distinct character. This is provided, as a frequent use-case for this struct is to provide String objects of variable length. For example, when generating indentation in text files, a std::basic_ostream
might be faster filled with spaces using a local variable of this type than putting character by character to the stream in a loop.
The type's name uses the word "local" because usually it is used with local (stack allocated) variables.
TChar | The character type. Alias names for C++ character types exist with
|
Defaults to character.
TLength | The length of the local buffer. Defaults to 128 bytes. |
Definition at line 647 of file characters.hpp.
#include <characters.hpp>
Public Static Field Index: | |
static constexpr size_t | Alignment |
Public Field Index: | |
TChar | buffer [TLength] |
The buffer. | |
Public Method Index: | |
constexpr | AlignedCharArray () noexcept=default |
Default constructor. Leaves the characters uninitialized. | |
constexpr | AlignedCharArray (TChar fillChar) noexcept |
constexpr const TChar * | Buffer () const noexcept |
constexpr TChar * | Buffer () noexcept |
constexpr void | Fill (TChar fillChar) noexcept |
constexpr integer | Length () const noexcept |
|
staticconstexpr |
The alignment of the field buffer. Because this is the first (and only) field, this struct itself shares this alignment.
Definition at line 650 of file characters.hpp.
TChar buffer[TLength] |
The buffer.
Definition at line 655 of file characters.hpp.
|
inlineconstexprnoexcept |
Constructor taking a character to initialize the buffer with.
fillChar | The character to fill this local buffer with. |
Definition at line 662 of file characters.hpp.
|
inlineconstexprnoexcept |
Returns a pointer to the internal buffer.
Definition at line 670 of file characters.hpp.
|
inlineconstexprnoexcept |
Returns a pointer to the internal buffer.
Definition at line 666 of file characters.hpp.
|
inlineconstexprnoexcept |
Fills the buffer with given fillChar.
fillChar | The character to fill this local buffer with. |
Definition at line 678 of file characters.hpp.
|
inlineconstexprnoexcept |
Returns the number of characters in this buffer.
Definition at line 674 of file characters.hpp.