16 #include "LvArrayConfig.hpp" 34 template<
typename T >
76 m_capacity( src.m_capacity )
87 template< typename _T=T, typename=std::enable_if_t< std::is_const< _T >::value > >
102 m_capacity = src.m_capacity;
115 m_capacity = src.m_capacity;
118 src.m_data =
nullptr;
127 void reallocate( std::ptrdiff_t
const size, std::ptrdiff_t
const newCapacity )
130 T *
const newPtr =
reinterpret_cast< T *
>( std::malloc( newCapacity *
sizeof( T ) ) );
132 std::ptrdiff_t
const overlapAmount =
std::min( newCapacity, size );
137 m_capacity = newCapacity;
158 {
return m_capacity; }
173 template<
typename INDEX_TYPE >
176 {
return m_data[ i ]; }
181 T * LVARRAY_RESTRICT m_data =
nullptr;
184 std::ptrdiff_t m_capacity = 0;
void free()
Free the data in the buffer but does not destroy any values.
T value_type
Alias used in the bufferManipulation functions.
constexpr MallocBuffer(bool=true)
Constructor for creating an empty or uninitialized buffer.
LVARRAY_INTEL_CONSTEXPR MallocBuffer & operator=(MallocBuffer const &src)
Copy assignment operator, creates a shallow copy.
static constexpr bool hasShallowCopy
Signifies that the MallocBuffer's copy semantics are shallow.
void uninitializedMove(T *const LVARRAY_RESTRICT dst, std::ptrdiff_t const size, T *const LVARRAY_RESTRICT src)
Move construct values from the source to the destination.
constexpr MallocBuffer(MallocBuffer< std::remove_const_t< T > > const &src)
Create a copy of src with const T.
This class implements the default behavior for the Buffer methods related to execution space...
void reallocate(std::ptrdiff_t const size, std::ptrdiff_t const newCapacity)
Reallocate the buffer to the new capacity.
void destroy(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size)
Destory the values in the array.
void free(BUFFER &buf, std::ptrdiff_t const size)
Destroy the values in the buffer and free it's memory.
Contains functions for manipulating buffers.
std::ptrdiff_t capacity() const
constexpr T & operator[](INDEX_TYPE const i) const
constexpr MallocBuffer(MallocBuffer &&src)
Move constructor, creates a shallow copy.
LVARRAY_INTEL_CONSTEXPR MallocBuffer & operator=(MallocBuffer &&src)
Move assignment operator, creates a shallow copy.
Contains a bunch of macro definitions.
MallocBuffer(MallocBuffer const &src, std::ptrdiff_t)
Sized copy constructor, creates a shallow copy.
constexpr T * data() const
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > min(T const a, T const b)
Implements the Buffer interface using malloc and free.
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.