1 #ifndef DUNE_FEM_COMMON_STACKALLOCATOR_HH 2 #define DUNE_FEM_COMMON_STACKALLOCATOR_HH 9 #include <dune/common/nullptr.hh> 21 :
public std::stack< void * >
24 : objectSize_( objectSize )
28 : objectSize_( other.objectSize_ )
33 if( objectSize_ != other.objectSize_ )
35 objectSize_ = other.objectSize_;
43 for( ; !empty(); pop() )
44 ::
operator delete( top() );
49 void resize ( std::size_t newSize ) {
clear(); objectSize_ = newSize; }
52 std::size_t objectSize_;
60 template<
class T,
class S = UninitializedObjectStack * >
91 pointer
address ( reference x )
const {
return &x; }
92 const_pointer
address ( const_reference x )
const {
return &x; }
94 pointer
allocate ( size_type n,
typename rebind< void >::other::const_pointer hint =
nullptr )
96 assert( n <= max_size() );
97 if( !stack().empty() )
99 pointer p = (pointer) stack().top();
104 return (pointer) ::operator
new( stack().objectSize() );
109 assert( n <= max_size() );
113 size_type
max_size ()
const {
return stack().objectSize() /
sizeof( T ); }
115 template<
class... Args >
119 new( p ) T( std::forward< Args >( args )... );
125 template<
class,
class >
128 const Stack &stack ()
const {
return *stack_; }
129 Stack &stack () {
return *stack_; }
156 #endif // #ifndef DUNE_FEM_COMMON_STACKALLOCATOR_HH UninitializedObjectStack Stack
Definition: stackallocator.hh:77
const void * const_pointer
Definition: stackallocator.hh:141
void construct(pointer p, Args &&...args)
Definition: stackallocator.hh:116
void * pointer
Definition: stackallocator.hh:140
T & reference
Definition: stackallocator.hh:68
std::ptrdiff_t difference_type
Definition: stackallocator.hh:144
const_pointer address(const_reference x) const
Definition: stackallocator.hh:92
size_type max_size() const
Definition: stackallocator.hh:113
StackAllocator< U, S > other
Definition: stackallocator.hh:147
T value_type
Definition: stackallocator.hh:63
Definition: stackallocator.hh:75
void deallocate(pointer p, size_type n)
Definition: stackallocator.hh:107
S StackPtr
Definition: stackallocator.hh:78
StackAllocator(StackPtr stack)
Definition: stackallocator.hh:80
pointer address(reference x) const
Definition: stackallocator.hh:91
std::size_t objectSize() const
Definition: stackallocator.hh:47
StackAllocator(StackAllocator< U, S > &&other)
Definition: stackallocator.hh:86
StackAllocator(const StackAllocator &other)
Definition: stackallocator.hh:88
pointer allocate(size_type n, typename rebind< void >::other::const_pointer hint=nullptr)
Definition: stackallocator.hh:94
void resize(std::size_t newSize)
Definition: stackallocator.hh:49
std::ptrdiff_t difference_type
Definition: stackallocator.hh:72
UninitializedObjectStack(const UninitializedObjectStack &other)
Definition: stackallocator.hh:27
Definition: coordinate.hh:4
StackAllocator(StackAllocator &&other)
Definition: stackallocator.hh:89
void value_type
Definition: stackallocator.hh:138
std::size_t size_type
Definition: stackallocator.hh:143
Definition: stackallocator.hh:61
UninitializedObjectStack(std::size_t objectSize)
Definition: stackallocator.hh:23
std::size_t size_type
Definition: stackallocator.hh:71
Definition: stackallocator.hh:20
const T & const_reference
Definition: stackallocator.hh:69
void move(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:38
StackAllocator(const StackAllocator< U, S > &other)
Definition: stackallocator.hh:83
UninitializedObjectStack & operator=(const UninitializedObjectStack &other)
Definition: stackallocator.hh:31
~UninitializedObjectStack()
Definition: stackallocator.hh:39
void destroy(pointer p)
Definition: stackallocator.hh:122
StackAllocator< U, S > other
Definition: stackallocator.hh:75
T * pointer
Definition: stackallocator.hh:65
UninitializedObjectStack Stack
Definition: stackallocator.hh:149
void clear()
Definition: stackallocator.hh:41
const T * const_pointer
Definition: stackallocator.hh:66