|
| | InlineVector () noexcept=default |
| | Construct an empty sequence.
|
| |
| | InlineVector (std::initializer_list< T > init) noexcept |
| | Construct from a brace-enclosed list of elements (clamped to N; extra elements are dropped).
|
| |
| InlineVector & | operator= (std::initializer_list< T > init) noexcept |
| | Replace the contents from a brace-enclosed list (clamped to N; extra elements are dropped).
|
| |
| InlineVector & | assign (std::initializer_list< T > init) noexcept |
| | Replace the contents from a brace-enclosed list (clamped to N; extra elements are dropped).
|
| |
| std::size_t | size () const noexcept |
| | Number of elements currently stored.
|
| |
| bool | empty () const noexcept |
| | True if the sequence is empty.
|
| |
| void | reserve (std::size_t) noexcept |
| | No-op (inline storage never reallocates); present for API parity.
|
| |
| void | clear () noexcept |
| | Reset to an empty sequence (logical length only).
|
| |
| void | resize (std::size_t n) noexcept |
| | Set the logical length to n, value-initializing what changes.
|
| |
| T & | emplace_back () noexcept |
| | Append a default-constructed element and return a reference to it.
|
| |
| void | push_back (const T &v) noexcept |
| | Append a copy of v; once at capacity N, v is dropped.
|
| |
| void | push_back (T &&v) noexcept |
| | Append v by move; dropped once at capacity N (see above).
|
| |
| T & | back () noexcept |
| | Reference to the last element.
|
| |
| const T & | back () const noexcept |
| | Const reference to the last element.
|
| |
| T & | operator[] (std::size_t i) noexcept |
| | Access the element at i (no bounds checking).
|
| |
| const T & | operator[] (std::size_t i) const noexcept |
| | Access the element at i (no bounds checking).
|
| |
| T * | data () noexcept |
| | Mutable pointer to the underlying storage.
|
| |
| const T * | data () const noexcept |
| | Const pointer to the underlying storage.
|
| |
| T * | begin () noexcept |
| | Iterator to the first element.
|
| |
| T * | end () noexcept |
| | Iterator past the last element.
|
| |
| const T * | begin () const noexcept |
| | Const iterator to the first element.
|
| |
| const T * | end () const noexcept |
| | Const iterator past the last element.
|
| |
| bool | operator== (const InlineVector &o) const noexcept |
| | Content equality (same logical length and elements).
|
| |
| bool | operator!= (const InlineVector &o) const noexcept |
| | Negated operator==.
|
| |
template<typename T, std::size_t N>
class sofab::InlineVector< T, N >
Fixed-capacity, heap-free sequence of up to N elements of type T.
The embedded-friendly counterpart of std::vector<T> for every array a schema bounds with a count: native scalars as well as strings, blobs, structs/unions and nested arrays. Elements live in an inline std::array, so the storage never reallocates and an element being filled across IStreamImpl::feed chunks stays address-stable — strictly safer than a std::vector + reserve.
resize is what marks this type as a resizable destination to IStreamImpl::readArray, which sizes it to the wire element count. That count IS the array's length (MESSAGE_SPEC §3); N is the schema count, a capacity that bounds it and never adds to it.
A logical length (size, <= N) is tracked separately from the capacity N: an array shorter than its schema count holds only size elements. This is why the type is neither a plain std::array<T,N> (always length N) nor a heap-backed std::vector.
- Warning
- Historically this was an aggregate with a public, default-zero length, so a natural brace-init such as
v = {a, b, c} silently filled the storage while leaving the logical length at 0 — the field then encoded as empty. The initializer_list constructor/assignment below make the type a non-aggregate, so that brace-init now sets size correctly instead of corrupting the wire.
- Template Parameters
-
| T | Element type. |
| N | Maximum number of elements. |
Definition at line 1158 of file sofab.hpp.
template<typename T , std::size_t N>
Append a copy of v; once at capacity N, v is dropped.
The assignment-time clamp of the static storage: elements past N are left out and the ones already held are kept, so a filled container holds the first N values it was given. (emplace_back, the decode-side binder, reuses the last slot instead.)
Definition at line 1282 of file sofab.hpp.
template<typename T , std::size_t N>
Set the logical length to n, value-initializing what changes.
The std::vector member of the container API this type mirrors, and the one IStreamImpl::readArray and the wrapper-array collectors probe for: readArray resizes a resizable destination and value-initializes a fixed-extent one, and without this method an InlineVector matched neither — it fell to the fixed-extent branch, which assigned a default-constructed container and so set the logical length to 0. The decode then bound an empty span and dropped the array silently. With resize present, readArray keeps ownership of the tag / bound / reset / bind order it documents, for inline storage too.
Slots that enter or leave the logical range are set to T{}, so the elements a shorter value no longer covers cannot be observed through a later grow. n above the capacity N is clamped to N — the callers that can reject an over-capacity count do so before resizing (readArray checks the schema count first), and a heap-free container has nowhere to put the excess.
- Parameters
-
Definition at line 1243 of file sofab.hpp.