32 #ifndef MADNESS_WORLD_STACK_H__INCLUDED
33 #define MADNESS_WORLD_STACK_H__INCLUDED
47 #include <type_traits>
58 template <
typename T,
bool isPod>
72 while(first != last) {
84 for (; first != last; ++first, ++dest) {
85 ::new (dest)
T(std::move(*first));
96 std::uninitialized_copy(first, last, dest);
105 template <
typename T>
127 std::memcpy(dest, first, (last - first) *
sizeof(
T));
138 std::memcpy(dest, first, (last - first) *
sizeof(
T));
153 template <
typename T,
unsigned int N>
186 throw std::bad_alloc();
188 return reinterpret_cast<T*
>(buffer);
Dynamically sized Stack with small stack size optimization.
Definition: stack.h:154
bool is_small() const
Check if the stack is using the small buffer to store data.
Definition: stack.h:176
bool empty() const
Check if the stack is empty.
Definition: stack.h:387
T * data_
Pointer to the stack data.
Definition: stack.h:162
const T * data() const
Data accessor.
Definition: stack.h:417
void reset()
Empty the stack and free memory.
Definition: stack.h:406
reference top()
Get the last item pushed onto the stack.
Definition: stack.h:355
size_type capacity_
The maximum size, in elements, of the data_ buffer.
Definition: stack.h:164
T value_type
Type of the stack elements.
Definition: stack.h:156
size_type size_
Number of elements on the stack.
Definition: stack.h:163
const T & const_reference
Element constant reference type.
Definition: stack.h:158
void move(Stack< T, N > &other)
Definition: stack.h:195
void clear()
Empty the stack.
Definition: stack.h:397
T * allocate(const size_type n)
Allocate a raw buffer.
Definition: stack.h:183
size_type size() const volatile
Size accessor.
Definition: stack.h:377
void push(const_reference value)
Push a new item onto the stack.
Definition: stack.h:318
Stack(Stack< T, N > &&other)
Move constructor.
Definition: stack.h:254
char buffer_[sizeof(T) *N]
Static buffer for storing a small number of elements.
Definition: stack.h:165
Stack()
Construct an empty stack.
Definition: stack.h:226
T * data()
Data accessor.
Definition: stack.h:422
bool empty() const volatile
Check if the stack is empty.
Definition: stack.h:392
Stack< T, N > & operator=(const Stack< T, N > &other)
Assignment operator.
Definition: stack.h:263
void pop()
Pop an item off of the stack.
Definition: stack.h:345
~Stack()
Destructor.
Definition: stack.h:308
const_reference top() const
Get the last item pushed onto the stack.
Definition: stack.h:364
size_type capacity() const
Capacity accessor.
Definition: stack.h:382
Stack(const Stack< T, N > &other)
Copy constructor.
Definition: stack.h:238
size_type size() const
Size accessor.
Definition: stack.h:372
Stack< T, N > & operator=(Stack< T, N > &&other)
Move assignment operator.
Definition: stack.h:297
detail::StackBase< T, std::is_standard_layout< T >::value &&std::is_trivial< T >::value > StackBase_
Definition: stack.h:167
unsigned int size_type
An unsigned integral type.
Definition: stack.h:159
void deallocate()
Deallocate memory.
Definition: stack.h:220
T & reference
Element reference type.
Definition: stack.h:157
static void uninitialized_move(T *first, T *last, T *dest)
Move a range of POD objects to an uninitialized buffer.
Definition: stack.h:124
static void destroy(T *)
Destroy a POD object (no op).
Definition: stack.h:112
static void destroy(T *, T *)
Destroy a range of POD objects (no op).
Definition: stack.h:117
static void uninitialized_copy(T *first, T *last, T *dest)
Copy a range of POD objects to an uninitialized buffer.
Definition: stack.h:135
Base class for Stack which implements basic memory operations for non-POD objects.
Definition: stack.h:59
static void destroy(T *first, T *last)
Destroy a range of non-POD objects.
Definition: stack.h:71
static void destroy(T *ptr)
Destroy a non-POD object.
Definition: stack.h:65
static void uninitialized_copy(T *first, T *last, T *dest)
Copy a range of POD objects.
Definition: stack.h:95
static void uninitialized_move(T *first, T *last, T *dest)
Move a range of POD objects.
Definition: stack.h:83
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
Defines madness::MadnessException for exception handling.
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition: madness_exception.h:134
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
#define N
Definition: testconv.cc:37
double u(const double x, const double expnt)
Definition: testperiodic.cc:56