From Jason Turner

[queue]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp17gnlm8_/{from.md → to.md} +31 -32
tmp/tmp17gnlm8_/{from.md → to.md} RENAMED
@@ -9,15 +9,16 @@ particular, `list` ([[list]]) and `deque` ([[deque]]) can be used.
9
  ``` cpp
10
  namespace std {
11
  template <class T, class Container = deque<T>>
12
  class queue {
13
  public:
14
- typedef typename Container::value_type value_type;
15
- typedef typename Container::reference reference;
16
- typedef typename Container::const_reference const_reference;
17
- typedef typename Container::size_type size_type;
18
- typedef Container container_type;
 
19
  protected:
20
  Container c;
21
 
22
  public:
23
  explicit queue(const Container&);
@@ -34,17 +35,23 @@ namespace std {
34
  const_reference front() const { return c.front(); }
35
  reference back() { return c.back(); }
36
  const_reference back() const { return c.back(); }
37
  void push(const value_type& x) { c.push_back(x); }
38
  void push(value_type&& x) { c.push_back(std::move(x)); }
39
- template <class... Args> void emplace(Args&&... args)
40
- { c.emplace_back(std::forward<Args>(args)...); }
41
  void pop() { c.pop_front(); }
42
- void swap(queue& q) noexcept(noexcept(swap(c, q.c)))
43
  { using std::swap; swap(c, q.c); }
44
  };
45
 
 
 
 
 
 
 
46
  template <class T, class Container>
47
  bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
48
  template <class T, class Container>
49
  bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
50
  template <class T, class Container>
@@ -79,91 +86,80 @@ explicit queue(Container&& cont = Container());
79
 
80
  *Effects:*  Initializes `c` with `std::move(cont)`.
81
 
82
  #### `queue` constructors with allocators <a id="queue.cons.alloc">[[queue.cons.alloc]]</a>
83
 
84
- If `uses_allocator<container_type, Alloc>::value` is `false` the
85
- constructors in this subclause shall not participate in overload
86
- resolution.
87
 
88
  ``` cpp
89
- template <class Alloc>
90
- explicit queue(const Alloc& a);
91
  ```
92
 
93
  *Effects:*  Initializes `c` with `a`.
94
 
95
  ``` cpp
96
- template <class Alloc>
97
- queue(const container_type& cont, const Alloc& a);
98
  ```
99
 
100
  *Effects:*  Initializes `c` with `cont` as the first argument and `a` as
101
  the second argument.
102
 
103
  ``` cpp
104
- template <class Alloc>
105
- queue(container_type&& cont, const Alloc& a);
106
  ```
107
 
108
  *Effects:*  Initializes `c` with `std::move(cont)` as the first argument
109
  and `a` as the second argument.
110
 
111
  ``` cpp
112
- template <class Alloc>
113
- queue(const queue& q, const Alloc& a);
114
  ```
115
 
116
  *Effects:*  Initializes `c` with `q.c` as the first argument and `a` as
117
  the second argument.
118
 
119
  ``` cpp
120
- template <class Alloc>
121
- queue(queue&& q, const Alloc& a);
122
  ```
123
 
124
  *Effects:*  Initializes `c` with `std::move(q.c)` as the first argument
125
  and `a` as the second argument.
126
 
127
  #### `queue` operators <a id="queue.ops">[[queue.ops]]</a>
128
 
129
  ``` cpp
130
  template <class T, class Container>
131
- bool operator==(const queue<T, Container>& x,
132
- const queue<T, Container>& y);
133
  ```
134
 
135
  *Returns:* `x.c == y.c`.
136
 
137
  ``` cpp
138
  template <class T, class Container>
139
- bool operator!=(const queue<T, Container>& x,
140
- const queue<T, Container>& y);
141
  ```
142
 
143
  *Returns:* `x.c != y.c`.
144
 
145
  ``` cpp
146
  template <class T, class Container>
147
- bool operator< (const queue<T, Container>& x,
148
- const queue<T, Container>& y);
149
  ```
150
 
151
  *Returns:* `x.c < y.c`.
152
 
153
  ``` cpp
154
  template <class T, class Container>
155
- bool operator<=(const queue<T, Container>& x,
156
- const queue<T, Container>& y);
157
  ```
158
 
159
  *Returns:* `x.c <= y.c`.
160
 
161
  ``` cpp
162
  template <class T, class Container>
163
- bool operator> (const queue<T, Container>& x,
164
- const queue<T, Container>& y);
165
  ```
166
 
167
  *Returns:* `x.c > y.c`.
168
 
169
  ``` cpp
@@ -179,7 +175,10 @@ template <class T, class Container>
179
  ``` cpp
180
  template <class T, class Container>
181
  void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
182
  ```
183
 
184
- *Effects:* `x.swap(y)`.
 
 
 
185
 
 
9
  ``` cpp
10
  namespace std {
11
  template <class T, class Container = deque<T>>
12
  class queue {
13
  public:
14
+ using value_type = typename Container::value_type;
15
+ using reference = typename Container::reference;
16
+ using const_reference = typename Container::const_reference;
17
+ using size_type = typename Container::size_type;
18
+ using container_type = Container;
19
+
20
  protected:
21
  Container c;
22
 
23
  public:
24
  explicit queue(const Container&);
 
35
  const_reference front() const { return c.front(); }
36
  reference back() { return c.back(); }
37
  const_reference back() const { return c.back(); }
38
  void push(const value_type& x) { c.push_back(x); }
39
  void push(value_type&& x) { c.push_back(std::move(x)); }
40
+ template <class... Args>
41
+ reference emplace(Args&&... args) { return c.emplace_back(std::forward<Args>(args)...); }
42
  void pop() { c.pop_front(); }
43
+ void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
44
  { using std::swap; swap(c, q.c); }
45
  };
46
 
47
+ template<class Container>
48
+ queue(Container) -> queue<typename Container::value_type, Container>;
49
+
50
+ template<class Container, class Allocator>
51
+ queue(Container, Allocator) -> queue<typename Container::value_type, Container>;
52
+
53
  template <class T, class Container>
54
  bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
55
  template <class T, class Container>
56
  bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
57
  template <class T, class Container>
 
86
 
87
  *Effects:*  Initializes `c` with `std::move(cont)`.
88
 
89
  #### `queue` constructors with allocators <a id="queue.cons.alloc">[[queue.cons.alloc]]</a>
90
 
91
+ If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
92
+ in this subclause shall not participate in overload resolution.
 
93
 
94
  ``` cpp
95
+ template <class Alloc> explicit queue(const Alloc& a);
 
96
  ```
97
 
98
  *Effects:*  Initializes `c` with `a`.
99
 
100
  ``` cpp
101
+ template <class Alloc> queue(const container_type& cont, const Alloc& a);
 
102
  ```
103
 
104
  *Effects:*  Initializes `c` with `cont` as the first argument and `a` as
105
  the second argument.
106
 
107
  ``` cpp
108
+ template <class Alloc> queue(container_type&& cont, const Alloc& a);
 
109
  ```
110
 
111
  *Effects:*  Initializes `c` with `std::move(cont)` as the first argument
112
  and `a` as the second argument.
113
 
114
  ``` cpp
115
+ template <class Alloc> queue(const queue& q, const Alloc& a);
 
116
  ```
117
 
118
  *Effects:*  Initializes `c` with `q.c` as the first argument and `a` as
119
  the second argument.
120
 
121
  ``` cpp
122
+ template <class Alloc> queue(queue&& q, const Alloc& a);
 
123
  ```
124
 
125
  *Effects:*  Initializes `c` with `std::move(q.c)` as the first argument
126
  and `a` as the second argument.
127
 
128
  #### `queue` operators <a id="queue.ops">[[queue.ops]]</a>
129
 
130
  ``` cpp
131
  template <class T, class Container>
132
+ bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
 
133
  ```
134
 
135
  *Returns:* `x.c == y.c`.
136
 
137
  ``` cpp
138
  template <class T, class Container>
139
+ bool operator!=(const queue<T, Container>& x, const queue<T, Container>& y);
 
140
  ```
141
 
142
  *Returns:* `x.c != y.c`.
143
 
144
  ``` cpp
145
  template <class T, class Container>
146
+ bool operator< (const queue<T, Container>& x, const queue<T, Container>& y);
 
147
  ```
148
 
149
  *Returns:* `x.c < y.c`.
150
 
151
  ``` cpp
152
  template <class T, class Container>
153
+ bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
 
154
  ```
155
 
156
  *Returns:* `x.c <= y.c`.
157
 
158
  ``` cpp
159
  template <class T, class Container>
160
+ bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
 
161
  ```
162
 
163
  *Returns:* `x.c > y.c`.
164
 
165
  ``` cpp
 
175
  ``` cpp
176
  template <class T, class Container>
177
  void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
178
  ```
179
 
180
+ *Remarks:* This function shall not participate in overload resolution
181
+ unless `is_swappable_v<Container>` is `true`.
182
+
183
+ *Effects:* As if by `x.swap(y)`.
184