aboutsummaryrefslogtreecommitdiff
path: root/src/stack.tpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stack.tpp')
-rw-r--r--src/stack.tpp6
1 files changed, 6 insertions, 0 deletions
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 <typename Item>
void Stack<Item>::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 <typename Item>
void Stack<Item>::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 <typename Item>
Item Stack<Item>::peek()
{
if (_items.size() == 0)
+ {
throw std::underflow_error("Tried to peek when stack size is 0");
+ }
return _items.back();
}