|
1 | 1 | #pragma once |
| 2 | +#include <stack> |
2 | 3 | #include "xr_vector.h" |
3 | | -//#include <stack> |
4 | 4 |
|
5 | | -// XXX: Use standard implementation? |
6 | | -//template <typename T, class container = xr_vector<T>> |
7 | | -//using xr_stack = std::stack<T, container>; |
8 | | - |
9 | | -// XXX: Use profiler or something to know if this is faster than std::stack |
10 | | -template <typename _Ty, class _C = xr_vector<_Ty>> |
11 | | -class xr_stack |
12 | | -{ |
13 | | -public: |
14 | | - using allocator_type = typename _C::allocator_type; |
15 | | - using value_type = typename allocator_type::value_type; |
16 | | - using size_type = typename allocator_type::size_type; |
17 | | - using _Myt = xr_stack<_Ty, _C>; |
18 | | - |
19 | | - allocator_type get_allocator() const { return c.get_allocator(); } |
20 | | - bool empty() const { return c.empty(); } |
21 | | - size_type size() const { return c.size(); } |
22 | | - value_type& top() { return c.back(); } |
23 | | - const value_type& top() const { return c.back(); } |
24 | | - void emplace(value_type&& _X) { c.emplace_back(_X); } |
25 | | - void push(value_type&& _X) { c.push_back(std::move(_X)); } |
26 | | - void push(const value_type& _X) { c.push_back(_X); } |
27 | | - void pop() { c.pop_back(); } |
28 | | - bool operator==(const _Myt& _X) const { return c == _X.c; } |
29 | | - bool operator!=(const _Myt& _X) const { return !(*this == _X); } |
30 | | - bool operator<(const _Myt& _X) const { return c < _X.c; } |
31 | | - bool operator>(const _Myt& _X) const { return _X < *this; } |
32 | | - bool operator<=(const _Myt& _X) const { return !(_X < *this); } |
33 | | - bool operator>=(const _Myt& _X) const { return !(*this < _X); } |
34 | | - |
35 | | -protected: |
36 | | - _C c; |
37 | | -}; |
| 5 | +template <typename T, class container = xr_vector<T>> |
| 6 | +using xr_stack = std::stack<T, container>; |
38 | 7 |
|
39 | 8 | #define DEFINE_STACK(T, N) using N = xr_stack<T>; |
0 commit comments