Skip to content

Commit

Permalink
Added empty() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alena Egorova committed Sep 21, 2016
1 parent 7db1a80 commit a5d4129
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ inline auto stack<T>::count() const noexcept -> size_t {
return count_;
}

template<typename T> /*noexcept*/
auto stack<T>::empty() const noexcept -> bool {
return (count_ == 0);
}

template<typename T> /*strong*/
auto stack<T>::top() const -> const T& {
if (count_ == 0) {
Expand Down
4 changes: 3 additions & 1 deletion include/stack.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <cstdlib>
#include <iostream>
#include <memory>
Expand All @@ -17,7 +18,8 @@ class stack {
stack(stack const & rhs); /*strong*/
~stack(); /*noexcept*/

auto count() const noexcept->size_t; /*noexcept*/
auto count() const noexcept -> size_t; /*noexcept*/
auto empty() const noexcept -> bool; /*noexcept*/
auto top() const -> const T&; /*strong*/
auto pop() -> void; /*strong*/
auto push(T const & value) -> void; /*strong*/
Expand Down

0 comments on commit a5d4129

Please sign in to comment.