From Jason Turner

[stack.defn]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpswue55n7/{from.md → to.md} +15 -8
tmp/tmpswue55n7/{from.md → to.md} RENAMED
@@ -3,15 +3,16 @@
3
  ``` cpp
4
  namespace std {
5
  template <class T, class Container = deque<T>>
6
  class stack {
7
  public:
8
- typedef typename Container::value_type value_type;
9
- typedef typename Container::reference reference;
10
- typedef typename Container::const_reference const_reference;
11
- typedef typename Container::size_type size_type;
12
- typedef Container container_type;
 
13
  protected:
14
  Container c;
15
 
16
  public:
17
  explicit stack(const Container&);
@@ -26,17 +27,23 @@ namespace std {
26
  size_type size() const { return c.size(); }
27
  reference top() { return c.back(); }
28
  const_reference top() const { return c.back(); }
29
  void push(const value_type& x) { c.push_back(x); }
30
  void push(value_type&& x) { c.push_back(std::move(x)); }
31
- template <class... Args> void emplace(Args&&... args)
32
- { c.emplace_back(std::forward<Args>(args)...); }
33
  void pop() { c.pop_back(); }
34
- void swap(stack& s) noexcept(noexcept(swap(c, s.c)))
35
  { using std::swap; swap(c, s.c); }
36
  };
37
 
 
 
 
 
 
 
38
  template <class T, class Container>
39
  bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
40
  template <class T, class Container>
41
  bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
42
  template <class T, class Container>
 
3
  ``` cpp
4
  namespace std {
5
  template <class T, class Container = deque<T>>
6
  class stack {
7
  public:
8
+ using value_type = typename Container::value_type;
9
+ using reference = typename Container::reference;
10
+ using const_reference = typename Container::const_reference;
11
+ using size_type = typename Container::size_type;
12
+ using container_type = Container;
13
+
14
  protected:
15
  Container c;
16
 
17
  public:
18
  explicit stack(const Container&);
 
27
  size_type size() const { return c.size(); }
28
  reference top() { return c.back(); }
29
  const_reference top() const { return c.back(); }
30
  void push(const value_type& x) { c.push_back(x); }
31
  void push(value_type&& x) { c.push_back(std::move(x)); }
32
+ template <class... Args>
33
+ reference emplace(Args&&... args) { return c.emplace_back(std::forward<Args>(args)...); }
34
  void pop() { c.pop_back(); }
35
+ void swap(stack& s) noexcept(is_nothrow_swappable_v<Container>)
36
  { using std::swap; swap(c, s.c); }
37
  };
38
 
39
+ template<class Container>
40
+ stack(Container) -> stack<typename Container::value_type, Container>;
41
+
42
+ template<class Container, class Allocator>
43
+ stack(Container, Allocator) -> stack<typename Container::value_type, Container>;
44
+
45
  template <class T, class Container>
46
  bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
47
  template <class T, class Container>
48
  bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
49
  template <class T, class Container>