59 std::vector<char> data;
79 codiAssert(dataPos + size *
sizeof(T) <= data.size());
81 T* castPointer =
reinterpret_cast<T*
>(&data.data()[dataPos]);
82 dataPos += size *
sizeof(T);
88 template<
typename T,
typename... Args>
90 T* value = alloc<T>(1);
91 new (value) T(std::forward<Args>(args)...);
100 CODI_EXCEPTION(
"Temporary memory can only be extended when no data is allocated.");
103 if (data.size() < newSize) {
104 data.resize(newSize);
112 std::fill(data.begin(), data.begin() + dataPos, 0);
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define codiAssert(x)
See codi::Config::EnableAssert.
Definition config.h:432
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
Allocator for temporary used memory.
Definition temporaryMemory.hpp:54
T * allocAndInit(Args &&... args)
Allocate a single entity of T and call the constructor with args.
Definition temporaryMemory.hpp:89
bool isEmpty()
Returns true if no data is currently allocated.
Definition temporaryMemory.hpp:71
void free()
Free all allocated memory. No destructors are called. Stored pointers and resources need to be deallo...
Definition temporaryMemory.hpp:110
TemporaryMemory()
Constructor.
Definition temporaryMemory.hpp:65
void ensureSize(size_t newSize)
Definition temporaryMemory.hpp:98
static size_t constexpr InitialDataSize
4 MiB of memory.
Definition temporaryMemory.hpp:55
TemporaryMemory(size_t initialSize)
Constructor.
Definition temporaryMemory.hpp:68
T * alloc(size_t size)
Allocate an array of type T with length size. Data is zero initialized. No constructors of T are call...
Definition temporaryMemory.hpp:78