stack

概要:スタックアダプター
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
template<
    class TType,
    class TContainer //= std::deque<TType>
>
class stack
{
public:
    typedef typename TContainer::value_type value_type;
//  typedef typename Container::reference reference;
//  typedef typename Container::const_reference const_reference;
    typedef typename TContainer::size_type size_type;
    typedef Container container_type;
    explicit stack(const Container& C_ = TContainer()) : container_(C_) {}
//  explicit stack(TContainer&& C_ = TContainer()) : container_(std::move(C_)) {}
    bool empty() const {return (container_.empty()); }
    size_type size() const {return (container_.size()); }
    value_type& top() {return (container_.back()); }
    const value_type& top() const {return (container_.back()); }
    void push(const value_type& value) {container_.push_back(value); }
//  void push(value_type&& value) { container_.push_back(std::move(value)); }
//  template <class... Args> void emplace(Args&&... args) { container_.emplace_back(std::forward<Args>(args)...); }
    void pop() {container_.pop_back(); }
//  void swap(stack& rhs) noexcept(noexcept(swap(container_, rhs.container_))) { std::swap(container_, rhs.container_); }
    bool operator==(const stack<TType, TContainer>& rhs) const {return (container_ == rhs.container_); }
    bool operator!=(const stack<TType, TContainer>& rhs) const {return (!(*this == rhs)); }
    bool operator< (const stack<TType, TContainer>& rhs) const {return (container_ < rhs.container_); }
    bool operator> (const stack<TType, TContainer>& rhs) const {return (rhs < *this); }
    bool operator<=(const stack<TType, TContainer>& rhs) const {return (!(rhs < *this)); }
    bool operator>=(const stack<TType, TContainer>& rhs) const {return (!(*this < rhs)); }
protected:
    TContainer container_;
};