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

Implements the Buffer interface using malloc and free. More...

#include <MallocBuffer.hpp>

Inheritance diagram for LvArray::MallocBuffer< T >:
Inheritance graph
[legend]

Public Types

using value_type = T
 Alias used in the bufferManipulation functions.
 

Public Member Functions

constexpr MallocBuffer (bool=true)
 Constructor for creating an empty or uninitialized buffer. More...
 
 MallocBuffer (MallocBuffer const &)=default
 Copy constructor, creates a shallow copy.
 
 MallocBuffer (MallocBuffer const &src, std::ptrdiff_t)
 Sized copy constructor, creates a shallow copy. More...
 
constexpr MallocBuffer (MallocBuffer &&src)
 Move constructor, creates a shallow copy. More...
 
template<typename _T = T, typename = std::enable_if_t< std::is_const< _T >::value >>
constexpr MallocBuffer (MallocBuffer< std::remove_const_t< T > > const &src)
 Create a copy of src with const T. More...
 
LVARRAY_INTEL_CONSTEXPR MallocBufferoperator= (MallocBuffer const &src)
 Copy assignment operator, creates a shallow copy. More...
 
LVARRAY_INTEL_CONSTEXPR MallocBufferoperator= (MallocBuffer &&src)
 Move assignment operator, creates a shallow copy. More...
 
void reallocate (std::ptrdiff_t const size, std::ptrdiff_t const newCapacity)
 Reallocate the buffer to the new capacity. More...
 
void free ()
 Free the data in the buffer but does not destroy any values. More...
 
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 = true
 Signifies that the MallocBuffer's copy semantics are shallow.
 

Detailed Description

template<typename T>
class LvArray::MallocBuffer< T >

Implements the Buffer interface using malloc and free.

Template Parameters
Ttype of data that is contained in the buffer.

Both the copy constructor and copy assignment constructor perform a shallow copy of the source. Similarly the destructor does not free the allocation.

Note
The parent class bufferManipulation::VoidBuffer provides the default execution space related methods.

Definition at line 35 of file MallocBuffer.hpp.

Constructor & Destructor Documentation

◆ MallocBuffer() [1/4]

template<typename T >
constexpr LvArray::MallocBuffer< T >::MallocBuffer ( bool  = true)
inline

Constructor for creating an empty or uninitialized buffer.

Note
An uninitialized MallocBuffer is equivalent to an empty MallocBuffer and does not need to be free'd.

Definition at line 51 of file MallocBuffer.hpp.

◆ MallocBuffer() [2/4]

template<typename T >
LvArray::MallocBuffer< T >::MallocBuffer ( MallocBuffer< T > const &  src,
std::ptrdiff_t   
)
inline

Sized copy constructor, creates a shallow copy.

Parameters
srcThe buffer to be coppied.

Definition at line 65 of file MallocBuffer.hpp.

◆ MallocBuffer() [3/4]

template<typename T >
constexpr LvArray::MallocBuffer< T >::MallocBuffer ( MallocBuffer< T > &&  src)
inline

Move constructor, creates a shallow copy.

Parameters
srcThe buffer to be moved from, is empty after the move.

Definition at line 74 of file MallocBuffer.hpp.

◆ MallocBuffer() [4/4]

template<typename T >
template<typename _T = T, typename = std::enable_if_t< std::is_const< _T >::value >>
constexpr LvArray::MallocBuffer< T >::MallocBuffer ( MallocBuffer< std::remove_const_t< T > > 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 89 of file MallocBuffer.hpp.

Member Function Documentation

◆ capacity()

template<typename T >
std::ptrdiff_t LvArray::MallocBuffer< T >::capacity ( ) const
inline
Returns
Return the capacity of the buffer.

Definition at line 157 of file MallocBuffer.hpp.

◆ data()

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

Definition at line 164 of file MallocBuffer.hpp.

◆ free()

template<typename T >
void LvArray::MallocBuffer< T >::free ( )
inline

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

Note
To destroy the values and free the data call bufferManipulation::free.

Definition at line 146 of file MallocBuffer.hpp.

◆ operator=() [1/2]

template<typename T >
LVARRAY_INTEL_CONSTEXPR MallocBuffer& LvArray::MallocBuffer< T >::operator= ( MallocBuffer< T > const &  src)
inline

Copy assignment operator, creates a shallow copy.

Parameters
srcThe buffer to be copied.
Returns
*this.

Definition at line 100 of file MallocBuffer.hpp.

◆ operator=() [2/2]

template<typename T >
LVARRAY_INTEL_CONSTEXPR MallocBuffer& LvArray::MallocBuffer< T >::operator= ( MallocBuffer< T > &&  src)
inline

Move assignment operator, creates a shallow copy.

Parameters
srcThe buffer to be moved from, is empty after the move.
Returns
*this.

Definition at line 113 of file MallocBuffer.hpp.

◆ operator[]()

template<typename T >
template<typename INDEX_TYPE >
constexpr T& LvArray::MallocBuffer< T >::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 175 of file MallocBuffer.hpp.

◆ reallocate()

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

Reallocate the buffer to the new capacity.

Parameters
sizeThe number of values that are initialized in the buffer.
newCapacityThe new capacity of the buffer.

Definition at line 127 of file MallocBuffer.hpp.


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