tmp/tmpbazig6s7/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
####
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template<class T, class Container = deque<T>>
|
| 6 |
class stack {
|
|
@@ -13,26 +13,28 @@ namespace std {
|
|
| 13 |
|
| 14 |
protected:
|
| 15 |
Container c;
|
| 16 |
|
| 17 |
public:
|
|
|
|
| 18 |
explicit stack(const Container&);
|
| 19 |
-
explicit stack(Container&&
|
| 20 |
template<class Alloc> explicit stack(const Alloc&);
|
| 21 |
template<class Alloc> stack(const Container&, const Alloc&);
|
| 22 |
template<class Alloc> stack(Container&&, const Alloc&);
|
| 23 |
template<class Alloc> stack(const stack&, const Alloc&);
|
| 24 |
template<class Alloc> stack(stack&&, const Alloc&);
|
| 25 |
|
| 26 |
-
bool
|
| 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 |
-
|
|
|
|
| 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 |
|
|
@@ -40,25 +42,10 @@ namespace std {
|
|
| 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>
|
| 50 |
-
bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 51 |
-
template <class T, class Container>
|
| 52 |
-
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 53 |
-
template <class T, class Container>
|
| 54 |
-
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 55 |
-
template <class T, class Container>
|
| 56 |
-
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 57 |
-
template <class T, class Container>
|
| 58 |
-
void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 59 |
-
|
| 60 |
template<class T, class Container, class Alloc>
|
| 61 |
struct uses_allocator<stack<T, Container>, Alloc>
|
| 62 |
: uses_allocator<Container, Alloc>::type { };
|
| 63 |
}
|
| 64 |
```
|
|
|
|
| 1 |
+
#### Definition <a id="stack.defn">[[stack.defn]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template<class T, class Container = deque<T>>
|
| 6 |
class stack {
|
|
|
|
| 13 |
|
| 14 |
protected:
|
| 15 |
Container c;
|
| 16 |
|
| 17 |
public:
|
| 18 |
+
stack() : stack(Container()) {}
|
| 19 |
explicit stack(const Container&);
|
| 20 |
+
explicit stack(Container&&);
|
| 21 |
template<class Alloc> explicit stack(const Alloc&);
|
| 22 |
template<class Alloc> stack(const Container&, const Alloc&);
|
| 23 |
template<class Alloc> stack(Container&&, const Alloc&);
|
| 24 |
template<class Alloc> stack(const stack&, const Alloc&);
|
| 25 |
template<class Alloc> stack(stack&&, const Alloc&);
|
| 26 |
|
| 27 |
+
[[nodiscard]] bool empty() const { return c.empty(); }
|
| 28 |
size_type size() const { return c.size(); }
|
| 29 |
reference top() { return c.back(); }
|
| 30 |
const_reference top() const { return c.back(); }
|
| 31 |
void push(const value_type& x) { c.push_back(x); }
|
| 32 |
void push(value_type&& x) { c.push_back(std::move(x)); }
|
| 33 |
template<class... Args>
|
| 34 |
+
decltype(auto) emplace(Args&&... args)
|
| 35 |
+
{ return c.emplace_back(std::forward<Args>(args)...); }
|
| 36 |
void pop() { c.pop_back(); }
|
| 37 |
void swap(stack& s) noexcept(is_nothrow_swappable_v<Container>)
|
| 38 |
{ using std::swap; swap(c, s.c); }
|
| 39 |
};
|
| 40 |
|
|
|
|
| 42 |
stack(Container) -> stack<typename Container::value_type, Container>;
|
| 43 |
|
| 44 |
template<class Container, class Allocator>
|
| 45 |
stack(Container, Allocator) -> stack<typename Container::value_type, Container>;
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
template<class T, class Container, class Alloc>
|
| 48 |
struct uses_allocator<stack<T, Container>, Alloc>
|
| 49 |
: uses_allocator<Container, Alloc>::type { };
|
| 50 |
}
|
| 51 |
```
|