GEOSX
Public Types | Public Member Functions | Static Public Attributes | List of all members
LvArray::StackBuffer< T, LENGTH > Class Template Reference

This class implements the Buffer interface using a c-array. More...

#include <StackBuffer.hpp>

Inheritance diagram for LvArray::StackBuffer< T, LENGTH >:
Inheritance graph
[legend]

Public Types

using value_type = T
 Alias used in the bufferManipulation functions.
 

Public Member Functions

constexpr StackBuffer (bool=true)
 Constructor for creating an empty/uninitialized buffer. More...
 
constexpr StackBuffer (StackBuffer const &src, std::ptrdiff_t)
 Sized copy constructor, creates a deep copy. More...
 
template<typename _T = T, typename = std::enable_if_t< std::is_const< _T >::value >>
constexpr StackBuffer (StackBuffer< std::remove_const_t< T >, LENGTH > const &src)
 Create a copy of src with const T. More...
 
void reallocate (std::ptrdiff_t const size, std::ptrdiff_t const newCapacity)
 Notionally this method reallocates the buffer, but since the StackBuffer is sized at compile time all this does is check that newCapacity doesn't exceed LENGTH. More...
 
constexpr void free ()
 Free the data in the buffer but does not destroy any values. More...
 
constexpr std::ptrdiff_t capacity () const
 
constexpr T * data () const
 
template<typename INDEX_TYPE >
constexpr T & operator[] (INDEX_TYPE const i) const
 
- Public Member Functions inherited from LvArray::bufferManipulation::VoidBuffer
void moveNested (MemorySpace const space, std::ptrdiff_t const size, bool const touch) const
 Move the buffer to the given execution space, optionally touching it. More...
 
void move (MemorySpace const space, bool const touch) const
 Move the buffer to the given execution space, optionally touching it. More...
 
void registerTouch (MemorySpace const space) const
 Touch the buffer in the given space. More...
 
template<typename = VoidBuffer>
void setName (std::string const &name)
 Set the name associated with this buffer. More...
 

Static Public Attributes

static constexpr bool hasShallowCopy = false
 Signifies that the StackBuffer's copy semantics are deep.
 

Detailed Description

template<typename T, int LENGTH>
class LvArray::StackBuffer< T, LENGTH >

This class implements the Buffer interface using a c-array.

Template Parameters
Ttype of data that is contained in the buffer. T must be both trivially copyable and trivially destructable.
LENGTHthe length of the buffer.
Note
Unlike the standard Buffer classes the StackBuffer does not permit making shallow copies.
The parent class provides the default execution space related methods.

Definition at line 40 of file StackBuffer.hpp.

Constructor & Destructor Documentation

◆ StackBuffer() [1/3]

template<typename T , int LENGTH>
constexpr LvArray::StackBuffer< T, LENGTH >::StackBuffer ( bool  = true)
inline

Constructor for creating an empty/uninitialized buffer.

Note
For the StackBuffer an uninitialized buffer is equivalent to an empty buffer.

Definition at line 56 of file StackBuffer.hpp.

◆ StackBuffer() [2/3]

template<typename T , int LENGTH>
constexpr LvArray::StackBuffer< T, LENGTH >::StackBuffer ( StackBuffer< T, LENGTH > const &  src,
std::ptrdiff_t   
)
inline

Sized copy constructor, creates a deep copy.

Parameters
srcThe buffer to be coppied.

Definition at line 64 of file StackBuffer.hpp.

◆ StackBuffer() [3/3]

template<typename T , int LENGTH>
template<typename _T = T, typename = std::enable_if_t< std::is_const< _T >::value >>
constexpr LvArray::StackBuffer< T, LENGTH >::StackBuffer ( StackBuffer< std::remove_const_t< T >, LENGTH > const &  src)
inline

Create a copy of src with const T.

Template Parameters
_TA dummy parameter to allow enable_if, do not specify.
Parameters
srcThe buffer to copy.

Definition at line 75 of file StackBuffer.hpp.

Member Function Documentation

◆ capacity()

template<typename T , int LENGTH>
constexpr std::ptrdiff_t LvArray::StackBuffer< T, LENGTH >::capacity ( ) const
inline
Returns
Return the capacity of the buffer.

Definition at line 103 of file StackBuffer.hpp.

◆ data()

template<typename T , int LENGTH>
constexpr T* LvArray::StackBuffer< T, LENGTH >::data ( ) const
inline
Returns
Return a pointer to the beginning of the buffer.

Definition at line 110 of file StackBuffer.hpp.

◆ free()

template<typename T , int LENGTH>
constexpr void LvArray::StackBuffer< T, LENGTH >::free ( )
inline

Free the data in the buffer but does not destroy any values.

Note
For this class this is a no-op since T must be trivially destructable.

Definition at line 96 of file StackBuffer.hpp.

◆ operator[]()

template<typename T , int LENGTH>
template<typename INDEX_TYPE >
constexpr T& LvArray::StackBuffer< T, LENGTH >::operator[] ( INDEX_TYPE const  i) const
inline
Template Parameters
INDEX_TYPEthe type used to index into the values.
Returns
The value at position i .
Parameters
iThe position of the value to access.
Note
No bounds checks are performed.

Definition at line 121 of file StackBuffer.hpp.

◆ reallocate()

template<typename T , int LENGTH>
void LvArray::StackBuffer< T, LENGTH >::reallocate ( std::ptrdiff_t const  size,
std::ptrdiff_t const  newCapacity 
)
inline

Notionally this method reallocates the buffer, but since the StackBuffer is sized at compile time all this does is check that newCapacity doesn't exceed LENGTH.

Parameters
sizeThe current size of the buffer, not used.
newCapacitythe new capacity of the buffer.

Definition at line 86 of file StackBuffer.hpp.


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