Repository navigation
TArray
#include <certpp/io/array.hpp> --- certpp
Template: template <typename T>
Represents an array of elements of type T.
Constructs an empty array of the specified type.
-
type--- The type of the array.
Copy constructor for the array.
-
other--- The array to copy from.
Constructs an array by copying elements from a span.
-
span--- The span containing elements to copy.
Constructs an array by copying elements from a read-only span.
-
span--- The read-only span containing elements to copy.
Move constructor for the array.
-
other--- The array to move from.
Destructor for the array. Clears the array and trims excess capacity.
Copy assignment operator for the array.
-
other--- The array to copy from.
Returns: A reference to the current array.
Move assignment operator for the array.
-
other--- The array to move from.
Returns: A reference to the current array.
Assigns elements from a span to the array.
-
span--- The span containing elements to assign.
Returns: A reference to the current array.
Wraps the array around an existing static buffer.
-
array--- The array to modify. -
p--- The pointer to the static buffer. -
size--- The size of the static buffer. -
fixed--- Whether the wrapped array should also be marked fixed (rejecting reserve()/trimExcess()).
Marks the array as fixed.
Checks if the array contains any elements.
Checks if the array is empty.
Checks if the array is empty.
Provides access to the element at the specified index.
-
index--- The index of the element to access.
Returns: A reference to the element at the specified index.
Provides access to the element at the specified index (const version).
-
index--- The index of the element to access.
Returns: A const reference to the element at the specified index.
Returns an iterator to the beginning of the array.
Returns an iterator to the end of the array.
Returns the capacity of the array.
Returns the type of the array.
Returns the number of elements in the array.
Clears the array by destroying all elements.
Reserves memory for at least the specified capacity.
-
cap--- The desired capacity.
Returns: True if the reservation was successful, false otherwise.
Resizes the array to the specified size.
-
size--- The desired size.
Returns: True if the resize was successful, false otherwise.
Trims the excess capacity of the array, reducing it to match the current size.
Returns: True if the trim was successful, false otherwise.
Adds a new element to the end of the array.
-
value--- The value to be added to the array.
Returns: True if the addition was successful, false otherwise.
Adds a new element to the end of the array using move semantics.
-
value--- The value to be added to the array.
Returns: True if the addition was successful, false otherwise.
Removes the element at the specified index from the array.
-
index--- The index of the element to be removed.
Returns: True if the removal was successful, false otherwise.
Removes a range of elements from the array starting at the specified index.
-
index--- The starting index of the elements to be removed. -
count--- The number of elements to be removed.
Returns: The number of elements actually removed.
Inserts a new element at the specified index using copy semantics.
-
index--- The index at which the element should be inserted. -
value--- The value to be inserted.
Returns: True if the insertion was successful, false otherwise.
Inserts a new element at the specified index using move semantics.
-
index--- The index at which the element should be inserted. -
value--- The value to be inserted.
Returns: True if the insertion was successful, false otherwise.
Removes the last element from the array and stores it in the provided reference.
-
value--- A reference to store the removed element.
Returns: True if an element was removed, false if the array was empty.
Removes the last element from the array without storing it.
Returns: True if an element was removed, false if the array was empty.
Collects bytes into a growable TArray<uint8_t>, the array type the library's own byte-producing calls fill. Every growing call reports failure with a bool rather than throwing, and reserve() up front turns one reallocation per add() into one in total.
// given: SReadOnlyByteSpan source
TArray<uint8_t> bytes;
if (!bytes.reserve(source.size)) {
return;
}
for (size_t i = 0; i < source.size; ++i) {
if (!bytes.add(source.data[i])) {
return;
}
}
// A leading zero byte is not part of an unsigned magnitude; remove() shifts the tail down
// and reports false only for an out-of-range index.
while (bytes.size() > 1 && bytes[0] == 0x00) {
if (!bytes.remove(0)) {
return;
}
}Reference generated from certpp/io/array.hpp at commit 0834b29 (v1.0.1). The header is authoritative --- if this page disagrees with it, the header is right and this page needs regenerating.