Block-Structured AMR Software Framework
AMReX_Stack.H
Go to the documentation of this file.
1 #ifndef AMREX_STACK_H_
2 #define AMREX_STACK_H_
3 
4 namespace amrex {
5 
6 template <typename T, int N>
7 struct Stack
8 {
9 public:
10  constexpr void push (T v) { m_data[m_size++] = v; }
11  constexpr void pop () { --m_size; }
12  [[nodiscard]] constexpr bool empty () const { return m_size == 0; }
13  [[nodiscard]] constexpr int size () const { return m_size; }
14  [[nodiscard]] constexpr T const& top () const { return m_data[m_size-1]; }
15  [[nodiscard]] constexpr T & top () { return m_data[m_size-1]; }
16  [[nodiscard]] constexpr T operator[] (int i) const { return m_data[i]; }
17 private:
18  T m_data[N];
19  int m_size = 0;
20 };
21 
22 }
23 
24 #endif
Definition: AMReX_Amr.cpp:49
Definition: AMReX_Stack.H:8
T m_data[N]
Definition: AMReX_Stack.H:18
constexpr void push(T v)
Definition: AMReX_Stack.H:10
constexpr int size() const
Definition: AMReX_Stack.H:13
constexpr T operator[](int i) const
Definition: AMReX_Stack.H:16
constexpr bool empty() const
Definition: AMReX_Stack.H:12
constexpr void pop()
Definition: AMReX_Stack.H:11
int m_size
Definition: AMReX_Stack.H:19
constexpr T & top()
Definition: AMReX_Stack.H:15
constexpr T const & top() const
Definition: AMReX_Stack.H:14