SpECTRE  v2024.09.29
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
DynamicBuffer< T > Class Template Reference

A dynamically sized vector of DataVectors. More...

#include <DynamicBuffer.hpp>

Public Member Functions

 DynamicBuffer (size_t number_of_vectors, size_t number_of_grid_points)
 
 DynamicBuffer (DynamicBuffer &&other)=default
 
DynamicBufferoperator= (DynamicBuffer &&other)=default
 
 DynamicBuffer (const DynamicBuffer &other)
 
DynamicBufferoperator= (const DynamicBuffer &other)
 
T & operator[] (size_t index)
 
T & at (size_t index)
 
const T & operator[] (size_t index) const
 
const T & at (size_t index) const
 
auto begin ()
 
auto end ()
 
auto begin () const
 
auto end () const
 
size_t size () const
 
void pup (PUP::er &p)
 

Static Public Attributes

static constexpr bool is_data_vector_type = std::is_same_v<DataVector, T>
 

Friends

template<typename LocalT >
bool operator== (const DynamicBuffer< LocalT > &lhs, const DynamicBuffer< LocalT > &rhs)
 

Detailed Description

template<typename T>
class DynamicBuffer< T >

A dynamically sized vector of DataVectors.

For convenience it can also be instantiated for fundamental types.

Details

This class is useful when one wants to create a std::vector<T> with a size that is unknown at compile time. It allocates all DataVectors in a single memory chunk rather than allocating each individually. If the size of the vector is known at compile time, a TempBuffer object should be used instead.

Currently this can only be used for DataVectors, but if needed, it should be fairly straightforward to generalize to ComplexDataVector.

Constructor & Destructor Documentation

◆ DynamicBuffer()

template<typename T >
DynamicBuffer< T >::DynamicBuffer ( size_t  number_of_vectors,
size_t  number_of_grid_points 
)

Constructs a DynamicBuffer. The number_of_vectors corresponds to the number of DataVectors which are saved inside, each of which has size number_of_grid_points. number_of_grid_points has to be 1 if T is a fundamental type.


The documentation for this class was generated from the following file: