tmp/tmp0krq5rzm/{from.md → to.md}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
####
|
| 2 |
|
| 3 |
Any sequence container supporting operations `front()`, `back()`,
|
| 4 |
`push_back()` and `pop_front()` can be used to instantiate `queue`. In
|
| 5 |
-
particular, `list`
|
| 6 |
|
| 7 |
``` cpp
|
| 8 |
namespace std {
|
| 9 |
template<class T, class Container = deque<T>>
|
| 10 |
class queue {
|
|
@@ -17,28 +17,30 @@ namespace std {
|
|
| 17 |
|
| 18 |
protected:
|
| 19 |
Container c;
|
| 20 |
|
| 21 |
public:
|
|
|
|
| 22 |
explicit queue(const Container&);
|
| 23 |
-
explicit queue(Container&&
|
| 24 |
template<class Alloc> explicit queue(const Alloc&);
|
| 25 |
template<class Alloc> queue(const Container&, const Alloc&);
|
| 26 |
template<class Alloc> queue(Container&&, const Alloc&);
|
| 27 |
template<class Alloc> queue(const queue&, const Alloc&);
|
| 28 |
template<class Alloc> queue(queue&&, const Alloc&);
|
| 29 |
|
| 30 |
-
bool
|
| 31 |
size_type size() const { return c.size(); }
|
| 32 |
reference front() { return c.front(); }
|
| 33 |
const_reference front() const { return c.front(); }
|
| 34 |
reference back() { return c.back(); }
|
| 35 |
const_reference back() const { return c.back(); }
|
| 36 |
void push(const value_type& x) { c.push_back(x); }
|
| 37 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 38 |
template<class... Args>
|
| 39 |
-
|
|
|
|
| 40 |
void pop() { c.pop_front(); }
|
| 41 |
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
|
| 42 |
{ using std::swap; swap(c, q.c); }
|
| 43 |
};
|
| 44 |
|
|
@@ -46,23 +48,10 @@ namespace std {
|
|
| 46 |
queue(Container) -> queue<typename Container::value_type, Container>;
|
| 47 |
|
| 48 |
template<class Container, class Allocator>
|
| 49 |
queue(Container, Allocator) -> queue<typename Container::value_type, Container>;
|
| 50 |
|
| 51 |
-
template <class T, class Container>
|
| 52 |
-
bool operator==(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 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>
|
| 58 |
-
bool operator> (const queue<T, Container>& x, const queue<T, Container>& y);
|
| 59 |
-
template <class T, class Container>
|
| 60 |
-
bool operator>=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 61 |
-
template <class T, class Container>
|
| 62 |
-
bool operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
|
| 63 |
-
|
| 64 |
template<class T, class Container>
|
| 65 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 66 |
|
| 67 |
template<class T, class Container, class Alloc>
|
| 68 |
struct uses_allocator<queue<T, Container>, Alloc>
|
|
|
|
| 1 |
+
#### Definition <a id="queue.defn">[[queue.defn]]</a>
|
| 2 |
|
| 3 |
Any sequence container supporting operations `front()`, `back()`,
|
| 4 |
`push_back()` and `pop_front()` can be used to instantiate `queue`. In
|
| 5 |
+
particular, `list` [[list]] and `deque` [[deque]] can be used.
|
| 6 |
|
| 7 |
``` cpp
|
| 8 |
namespace std {
|
| 9 |
template<class T, class Container = deque<T>>
|
| 10 |
class queue {
|
|
|
|
| 17 |
|
| 18 |
protected:
|
| 19 |
Container c;
|
| 20 |
|
| 21 |
public:
|
| 22 |
+
queue() : queue(Container()) {}
|
| 23 |
explicit queue(const Container&);
|
| 24 |
+
explicit queue(Container&&);
|
| 25 |
template<class Alloc> explicit queue(const Alloc&);
|
| 26 |
template<class Alloc> queue(const Container&, const Alloc&);
|
| 27 |
template<class Alloc> queue(Container&&, const Alloc&);
|
| 28 |
template<class Alloc> queue(const queue&, const Alloc&);
|
| 29 |
template<class Alloc> queue(queue&&, const Alloc&);
|
| 30 |
|
| 31 |
+
[[nodiscard]] bool empty() const { return c.empty(); }
|
| 32 |
size_type size() const { return c.size(); }
|
| 33 |
reference front() { return c.front(); }
|
| 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>
|
| 40 |
+
decltype(auto) emplace(Args&&... args)
|
| 41 |
+
{ 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 |
|
|
|
|
| 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 |
void swap(queue<T, Container>& x, queue<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 55 |
|
| 56 |
template<class T, class Container, class Alloc>
|
| 57 |
struct uses_allocator<queue<T, Container>, Alloc>
|