From 9147551cd21d565f9503e3ebbcd2121e284d88d5 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 13 Feb 2022 20:55:06 +0100 Subject: style: fix curly positions & delete unused include --- src/stack.tpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/stack.tpp') diff --git a/src/stack.tpp b/src/stack.tpp index 405d493..b555a49 100644 --- a/src/stack.tpp +++ b/src/stack.tpp @@ -12,7 +12,9 @@ template void Stack::push(Item item) { if (_items.size() == _items.capacity()) + { throw std::overflow_error("Tried to push when stack is full"); + } _items.push_back(item); } @@ -21,7 +23,9 @@ template void Stack::pop() { if (_items.size() == 0) + { throw std::underflow_error("Tried to pop when stack size is 0"); + } _items.pop_back(); } @@ -30,7 +34,9 @@ template Item Stack::peek() { if (_items.size() == 0) + { throw std::underflow_error("Tried to peek when stack size is 0"); + } return _items.back(); } -- cgit v1.2.3-18-g5258