39template <
typename T, std::
size_t StaticArraySize>
70 void push(
const T& value) {
89 [[nodiscard]]
auto top() const noexcept -> const T& {
return *(
end_ - 1); }
96 [[nodiscard]]
auto top() noexcept -> T& {
return *(
end_ - 1); }
111 [[nodiscard]]
auto size() const noexcept ->
std::
size_t {
112 return static_cast<std::size_t
>(
end_ -
begin_);
117 alignas(
alignof(T))
char buffer_[
sizeof(T[StaticArraySize])]{};
Class of stacks using static arrays.
char buffer_[sizeof(T[StaticArraySize])]
Buffer for stack.
auto top() noexcept -> T &
Get the top value.
void pop() noexcept
Pop a value.
~static_stack()
Destructor.
void push(const T &value)
Push a value.
static_stack()
Constructor.
auto size() const noexcept -> std::size_t
Get the current number of values.
T * end_
Pointer to the past-the-end element in the buffer.
T * storage_end_
Pointer to the past-the-end storage in the buffer.
T * begin_
Pointer to the first element in the buffer.
auto top() const noexcept -> const T &
Get the top value.
auto empty() const noexcept -> bool
Check whether this stack is empty.
Definition of exceptions.
Definition of macros for logging.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.