Skip to content

Commit

Permalink
Use std::stack for xr_stack
Browse files Browse the repository at this point in the history
There's no difference basically..
  • Loading branch information
Xottab-DUTY committed Jan 6, 2018
1 parent 06fa47c commit f25a1be
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions src/xrCommon/xr_stack.h
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
#pragma once
#include <stack>
#include "xr_vector.h"
//#include <stack>

// XXX: Use standard implementation?
//template <typename T, class container = xr_vector<T>>
//using xr_stack = std::stack<T, container>;

// XXX: Use profiler or something to know if this is faster than std::stack
template <typename _Ty, class _C = xr_vector<_Ty>>
class xr_stack
{
public:
using allocator_type = typename _C::allocator_type;
using value_type = typename allocator_type::value_type;
using size_type = typename allocator_type::size_type;
using _Myt = xr_stack<_Ty, _C>;

allocator_type get_allocator() const { return c.get_allocator(); }
bool empty() const { return c.empty(); }
size_type size() const { return c.size(); }
value_type& top() { return c.back(); }
const value_type& top() const { return c.back(); }
void emplace(value_type&& _X) { c.emplace_back(_X); }
void push(value_type&& _X) { c.push_back(std::move(_X)); }
void push(const value_type& _X) { c.push_back(_X); }
void pop() { c.pop_back(); }
bool operator==(const _Myt& _X) const { return c == _X.c; }
bool operator!=(const _Myt& _X) const { return !(*this == _X); }
bool operator<(const _Myt& _X) const { return c < _X.c; }
bool operator>(const _Myt& _X) const { return _X < *this; }
bool operator<=(const _Myt& _X) const { return !(_X < *this); }
bool operator>=(const _Myt& _X) const { return !(*this < _X); }

protected:
_C c;
};
template <typename T, class container = xr_vector<T>>
using xr_stack = std::stack<T, container>;

#define DEFINE_STACK(T, N) using N = xr_stack<T>;

0 comments on commit f25a1be

Please sign in to comment.