#include "stack.hpp" #include #include template Stack::Stack(unsigned long capacity) { _items.reserve(capacity); } 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); } template void Stack::pop() { if (_items.size() == 0) { throw std::underflow_error("Tried to pop when stack size is 0"); } _items.pop_back(); } template Item Stack::peek() { if (_items.size() == 0) { throw std::underflow_error("Tried to peek when stack size is 0"); } return _items.back(); }