From 8792eb3159ee6f353b029819405a510593c8f5a5 Mon Sep 17 00:00:00 2001 From: LaEntropiaa Date: Sun, 15 Mar 2026 21:28:17 -0600 Subject: [PATCH] added peek, need testing --- include/stack.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/stack.h b/include/stack.h index de54ecb..65ca043 100644 --- a/include/stack.h +++ b/include/stack.h @@ -109,4 +109,14 @@ std::expected Stack::pop() { return std::expected(return_val); } +template +requires std::formattable +std::expected Stack::peek() { + if (this->len == 0) { + return std::unexpected(StackErr::empty); + } + + return std::expected(this->data[this->len - 1]); +} + #endif // !ST