17 #include "LvArrayConfig.hpp" 23 #include <type_traits> 39 template<
typename T,
int LENGTH >
43 static_assert( std::is_trivially_destructible< T >::value,
"The StackBuffer can only hold trivially copyable and destructable types." );
73 template< typename _T=T, typename=std::enable_if_t< std::is_const< _T >::value > >
86 void reallocate( std::ptrdiff_t
const size, std::ptrdiff_t
const newCapacity )
111 {
return const_cast< T *
>( m_data ); }
119 template<
typename INDEX_TYPE >
122 {
return const_cast< T *
>( m_data )[ i ]; }
#define LVARRAY_UNUSED_VARIABLE(X)
Mark X as an unused variable, used to silence compiler warnings.
constexpr StackBuffer(StackBuffer const &src, std::ptrdiff_t)
Sized copy constructor, creates a deep copy.
constexpr std::ptrdiff_t capacity() const
This class implements the default behavior for the Buffer methods related to execution space...
constexpr T * data() const
#define LVARRAY_ERROR_IF_GT(lhs, rhs)
Raise a hard error if one value compares greater than the other.
constexpr T & operator[](INDEX_TYPE const i) const
Contains functions for manipulating buffers.
static constexpr bool hasShallowCopy
Signifies that the StackBuffer's copy semantics are deep.
constexpr StackBuffer(StackBuffer< std::remove_const_t< T >, LENGTH > const &src)
Create a copy of src with const T.
T value_type
Alias used in the bufferManipulation functions.
constexpr StackBuffer(bool=true)
Constructor for creating an empty/uninitialized buffer.
constexpr void free()
Free the data in the buffer but does not destroy any values.
Contains a bunch of macro definitions.
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 class implements the Buffer interface using a c-array.
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.