LvArray
Public Types | Public Member Functions | Static Public Attributes | Private 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

Public Types

using value_type = T
 Alias used in the bufferManipulation functions.
 

Public Member Functions

LVARRAY_HOST_DEVICE constexpr StackBuffer (bool=true)
 Constructor for creating an empty/uninitialized buffer. More...
 
LVARRAY_HOST_DEVICE 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 >>
LVARRAY_HOST_DEVICE constexpr StackBuffer (StackBuffer< std::remove_const_t< T >, LENGTH > const &src)
 Create a copy of src with const T. More...
 
LVARRAY_HOST_DEVICE void reallocate (std::ptrdiff_t const size, MemorySpace const space, 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...
 
LVARRAY_HOST_DEVICE constexpr void free ()
 Free the data in the buffer but does not destroy any values. More...
 
LVARRAY_HOST_DEVICE constexpr std::ptrdiff_t capacity () const
 
LVARRAY_HOST_DEVICE constexpr T * data () const
 
template<typename INDEX_TYPE >
LVARRAY_HOST_DEVICE 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...
 
MemorySpace getPreviousSpace () const
 
void registerTouch (MemorySpace const space) const
 Touch the buffer in the given space. More...
 
template<typename = VoidBuffer>
LVARRAY_HOST_DEVICE 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.
 

Private Attributes

m_data [LENGTH]
 The c-array containing the values.
 

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.

Constructor & Destructor Documentation

◆ StackBuffer() [1/3]

template<typename T , int LENGTH>
LVARRAY_HOST_DEVICE 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.

◆ StackBuffer() [2/3]

template<typename T , int LENGTH>
LVARRAY_HOST_DEVICE 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.

◆ StackBuffer() [3/3]

template<typename T , int LENGTH>
template<typename _T = T, typename = std::enable_if_t< std::is_const< _T >::value >>
LVARRAY_HOST_DEVICE 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.

Member Function Documentation

◆ capacity()

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

◆ data()

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

◆ free()

template<typename T , int LENGTH>
LVARRAY_HOST_DEVICE 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.

◆ operator[]()

template<typename T , int LENGTH>
template<typename INDEX_TYPE >
LVARRAY_HOST_DEVICE 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.

◆ reallocate()

template<typename T , int LENGTH>
LVARRAY_HOST_DEVICE void LvArray::StackBuffer< T, LENGTH >::reallocate ( std::ptrdiff_t const  size,
MemorySpace const  space,
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.
spaceThe space to perform the reallocation in, not used.
newCapacitythe new capacity of the buffer.

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