ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::core::StdAllocator< T > Class Template Reference

#include <StdAllocator.h>

Public Types

using value_type = T
 T. More...
 

Public Member Functions

 StdAllocator ()=default
 Default constructor. More...
 
 StdAllocator (int device_id)
 Constructor from device. More...
 
 StdAllocator (const StdAllocator &)=default
 Default copy constructor. More...
 
StdAllocatoroperator= (const StdAllocator &)=default
 Default copy assignment operator. More...
 
 StdAllocator (StdAllocator &&)=default
 Default move constructor. More...
 
StdAllocatoroperator= (StdAllocator &&)=default
 Default move assignment operator. More...
 
template<typename U >
 StdAllocator (const StdAllocator< U > &other)
 Rebind copy constructor. More...
 
T * allocate (std::size_t n)
 Allocates memory of size n. More...
 
void deallocate (T *p, std::size_t n)
 Deallocates memory from pointer p of size n . More...
 
bool operator== (const StdAllocator &other) const
 Returns true if the instances are equal, false otherwise. More...
 
bool operator!= (const StdAllocator &other) const
 Returns true if the instances are not equal, false otherwise. More...
 
int GetDeviceID () const
 Returns the device on which memory is allocated. More...
 

Detailed Description

template<typename T>
class cloudViewer::core::StdAllocator< T >

Class satisfying the Allocator requirements defined by the C++ standard. This bridge makes the MemoryManager interface accessible to all classes and containers that use the standard Allocator interface.

This is particularly useful to allocate (potentially cached) GPU memory or different types of memory depending on the provided device.

Definition at line 23 of file StdAllocator.h.

Member Typedef Documentation

◆ value_type

template<typename T >
using cloudViewer::core::StdAllocator< T >::value_type = T

T.

Definition at line 26 of file StdAllocator.h.

Constructor & Destructor Documentation

◆ StdAllocator() [1/5]

template<typename T >
cloudViewer::core::StdAllocator< T >::StdAllocator ( )
default

Default constructor.

◆ StdAllocator() [2/5]

template<typename T >
cloudViewer::core::StdAllocator< T >::StdAllocator ( int  device_id)
inlineexplicit

Constructor from device.

Definition at line 32 of file StdAllocator.h.

◆ StdAllocator() [3/5]

template<typename T >
cloudViewer::core::StdAllocator< T >::StdAllocator ( const StdAllocator< T > &  )
default

Default copy constructor.

◆ StdAllocator() [4/5]

template<typename T >
cloudViewer::core::StdAllocator< T >::StdAllocator ( StdAllocator< T > &&  )
default

Default move constructor.

◆ StdAllocator() [5/5]

template<typename T >
template<typename U >
cloudViewer::core::StdAllocator< T >::StdAllocator ( const StdAllocator< U > &  other)
inline

Rebind copy constructor.

Definition at line 48 of file StdAllocator.h.

Member Function Documentation

◆ allocate()

template<typename T >
T* cloudViewer::core::StdAllocator< T >::allocate ( std::size_t  n)
inline

Allocates memory of size n.

Definition at line 51 of file StdAllocator.h.

References cloudViewer::core::Device::CUDA, and cloudViewer::core::MemoryManager::Malloc().

◆ deallocate()

template<typename T >
void cloudViewer::core::StdAllocator< T >::deallocate ( T *  p,
std::size_t  n 
)
inline

Deallocates memory from pointer p of size n .

Definition at line 58 of file StdAllocator.h.

References cloudViewer::core::Device::CUDA, and cloudViewer::core::MemoryManager::Free().

◆ GetDeviceID()

template<typename T >
int cloudViewer::core::StdAllocator< T >::GetDeviceID ( ) const
inline

Returns the device on which memory is allocated.

Definition at line 73 of file StdAllocator.h.

◆ operator!=()

template<typename T >
bool cloudViewer::core::StdAllocator< T >::operator!= ( const StdAllocator< T > &  other) const
inline

Returns true if the instances are not equal, false otherwise.

Definition at line 68 of file StdAllocator.h.

References cloudViewer::core::StdAllocator< T >::operator==().

◆ operator=() [1/2]

template<typename T >
StdAllocator& cloudViewer::core::StdAllocator< T >::operator= ( const StdAllocator< T > &  )
default

Default copy assignment operator.

◆ operator=() [2/2]

template<typename T >
StdAllocator& cloudViewer::core::StdAllocator< T >::operator= ( StdAllocator< T > &&  )
default

Default move assignment operator.

◆ operator==()

template<typename T >
bool cloudViewer::core::StdAllocator< T >::operator== ( const StdAllocator< T > &  other) const
inline

Returns true if the instances are equal, false otherwise.

Definition at line 63 of file StdAllocator.h.

Referenced by cloudViewer::core::StdAllocator< T >::operator!=().


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