Teuchos - Trilinos Tools Package
Version of the Day
|
Optional tracking allocator for Teuchos Memory Management classes. More...
#include <Teuchos_Details_Allocator.hpp>
Classes | |
struct | rebind |
Mapping to an Allocator for a different type U . More... | |
Public Types | |
typedef T | value_type |
Type of the template parameter of this class. More... | |
typedef T * | pointer |
Type of a pointer to T. More... | |
typedef const T * | const_pointer |
Type of a pointer to const T. More... | |
typedef T & | reference |
Type of a reference to T. More... | |
typedef const T & | const_reference |
Type of a reference to const T. More... | |
typedef AllocationLogger::size_type | size_type |
Type of the size of an allocation or deallocation. More... | |
typedef std::ptrdiff_t | difference_type |
Integer type representing the difference between two pointers. More... | |
Public Member Functions | |
Allocator () | |
Default constructor. More... | |
Allocator (const bool trackMemory, const bool verboseOutput) | |
Constructor. More... | |
template<class U > | |
Allocator (const Allocator< U > &src) | |
Copy constructor that takes an Allocator<U> for any U. More... | |
size_type | max_size () const |
Upper bound (possibly loose) on maximum allocation size. More... | |
value_type * | allocate (const size_type &n, const void *=0) |
Allocate an array of n instances of value_type. More... | |
void | deallocate (value_type *p, const size_type &n) |
Deallocate n instances of value_type. More... | |
size_type | curAllocInBytes () |
Current total allocation in bytes, over all Allocator<U>. More... | |
size_type | maxAllocInBytes () |
Max total allocation ("high water mark") in bytes, over all Allocator<U>. More... | |
void | construct (pointer p, const_reference val) |
Invoke the constructor of an instance of T , without allocating. More... | |
void | destroy (pointer p) |
Invoke the destructor of an instance of T , without deallocating. More... | |
Optional tracking allocator for Teuchos Memory Management classes.
T | The type of the entries in arrays to allocate. |
This class implements the C++ Standard Library's "Allocator" concept. It does "high water mark" tracking, and has the option to print to stderr
on allocations and deallocations.
Definition at line 188 of file Teuchos_Details_Allocator.hpp.
typedef T Teuchos::Details::Allocator< T >::value_type |
Type of the template parameter of this class.
Definition at line 210 of file Teuchos_Details_Allocator.hpp.
typedef T* Teuchos::Details::Allocator< T >::pointer |
Type of a pointer to T.
This is only needed for C++98, not for C++11 and newer.
Definition at line 215 of file Teuchos_Details_Allocator.hpp.
typedef const T* Teuchos::Details::Allocator< T >::const_pointer |
Type of a pointer to const T.
This is only needed for C++98, not for C++11 and newer.
Definition at line 219 of file Teuchos_Details_Allocator.hpp.
typedef T& Teuchos::Details::Allocator< T >::reference |
Type of a reference to T.
This is only needed for C++98, not for C++11 and newer.
Definition at line 223 of file Teuchos_Details_Allocator.hpp.
typedef const T& Teuchos::Details::Allocator< T >::const_reference |
Type of a reference to const T.
This is only needed for C++98, not for C++11 and newer.
Definition at line 227 of file Teuchos_Details_Allocator.hpp.
typedef AllocationLogger::size_type Teuchos::Details::Allocator< T >::size_type |
Type of the size of an allocation or deallocation.
This must match AllocationLogger::size_type (see above). If we didn't need this to have the same type as that, then we wouldn't need this typedef.
Definition at line 234 of file Teuchos_Details_Allocator.hpp.
Teuchos::Details::Allocator< T >::difference_type |
Integer type representing the difference between two pointers.
This is only needed for C++98, not for C++11 and newer. However, we want this typedef to exist in both cases. Thus, if C++11 is enabled, we use size_type above to compute this, in order to ensure consistency.
Definition at line 246 of file Teuchos_Details_Allocator.hpp.
|
inline |
Default constructor.
Definition at line 250 of file Teuchos_Details_Allocator.hpp.
|
inline |
Constructor.
trackMemory | [in] Whether to track memory usage at all. If false, verboseOutput is ignored. |
verboseOutput | [in] Whether to print on every allocation and deallocation. Even if this is true, trackMemory must also be true in order for this to work. |
Definition at line 261 of file Teuchos_Details_Allocator.hpp.
|
inline |
Copy constructor that takes an Allocator<U> for any U.
Definition at line 268 of file Teuchos_Details_Allocator.hpp.
|
inline |
Upper bound (possibly loose) on maximum allocation size.
Implementations of the Allocator concept should not NEED this method, but it makes the Clang compiler happy.
Definition at line 288 of file Teuchos_Details_Allocator.hpp.
|
inline |
Allocate an array of n instances of value_type.
n | [in] Number of entries in the array. |
The optional second argument provides an "allocation hint." This implementation ignores the hint.
Definition at line 300 of file Teuchos_Details_Allocator.hpp.
|
inline |
Deallocate n instances of value_type.
p | [in] Pointer to the array to deallocate. |
n | [in] Number of entries in the array p. |
Definition at line 312 of file Teuchos_Details_Allocator.hpp.
|
inline |
Current total allocation in bytes, over all Allocator<U>.
Definition at line 324 of file Teuchos_Details_Allocator.hpp.
|
inline |
Max total allocation ("high water mark") in bytes, over all Allocator<U>.
Definition at line 329 of file Teuchos_Details_Allocator.hpp.
|
inline |
Invoke the constructor of an instance of T
, without allocating.
p | [in] Pointer to an area of memory in which to construct a T instance, using placement new. |
val | [in] Argument to T's (copy) constructor. |
Definition at line 345 of file Teuchos_Details_Allocator.hpp.
|
inline |
Invoke the destructor of an instance of T
, without deallocating.
p | [in] Pointer to an instance of T to destroy. |
Definition at line 360 of file Teuchos_Details_Allocator.hpp.