added peek, need testing
This commit is contained in:
@@ -109,4 +109,14 @@ std::expected<T, StackErr> Stack<T>::pop() {
|
|||||||
return std::expected(return_val);
|
return std::expected(return_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
requires std::formattable<T, char>
|
||||||
|
std::expected<T, StackErr> Stack<T>::peek() {
|
||||||
|
if (this->len == 0) {
|
||||||
|
return std::unexpected(StackErr::empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::expected(this->data[this->len - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !ST
|
#endif // !ST
|
||||||
|
|||||||
Reference in New Issue
Block a user