Open CASCADE Technology  7.3.0
Data Structures | Public Types | Public Member Functions | Protected Attributes

NCollection_StdAllocator< T > Class Template Reference

Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5. More...

#include <NCollection_StdAllocator.hxx>

Data Structures

struct  rebind
 

Public Types

typedef T value_type
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 

Public Member Functions

 NCollection_StdAllocator ()
 Constructor. More...
 
 NCollection_StdAllocator (const Handle< NCollection_BaseAllocator > &theAlloc)
 Constructor. More...
 
template<typename U >
 NCollection_StdAllocator (const NCollection_StdAllocator< U > &Y)
 Copy constructor. More...
 
template<typename U >
NCollection_StdAllocatoroperator= (const NCollection_StdAllocator< U > &Y)
 Assignment operator. More...
 
pointer address (reference x) const
 Returns an object address. More...
 
const_pointer address (const_reference x) const
 Returns an object address. More...
 
pointer allocate (size_type n, const void *=0)
 Allocates memory for n objects. More...
 
void deallocate (pointer p, size_type)
 Frees previously allocated memory. More...
 
size_type max_size () const
 Returns the largest value for which method allocate might succeed. More...
 
void construct (pointer p, const_reference val)
 Constructs an object. More...
 
void destroy (pointer p)
 Destroys the object. More...
 
const Handle< NCollection_BaseAllocator > & Allocator () const
 Returns an underlying NCollection_BaseAllocator instance. More...
 

Protected Attributes

Handle< NCollection_BaseAllocatormyAlloc
 

Detailed Description

template<typename T>
class NCollection_StdAllocator< T >

Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5.

The allocator uses instance of the NCollection_BaseAllocator (sub)class for memory allocation/deallocation. The allocator can be used with standard containers (std::vector, std::map, etc) to take advantage of NCollection_IncAllocator which implements memory region concept, and hence to increase performance in specific cases.

The underlying NCollection_BaseAllocator instance can be received using the Allocator() method.

Example of use:

std::list<TopoDS_Shape, NCollection_StdAllocator<TopoDS_Shape> > aL (aSAlloc);
TopoDS_Solid aSolid = BRepPrimAPI_MakeBox (10., 20., 30.);
aL.push_back (aSolid);

Member Typedef Documentation

◆ const_pointer

template<typename T>
typedef const value_type* NCollection_StdAllocator< T >::const_pointer

◆ const_reference

template<typename T>
typedef const value_type& NCollection_StdAllocator< T >::const_reference

◆ difference_type

template<typename T>
typedef ptrdiff_t NCollection_StdAllocator< T >::difference_type

◆ pointer

template<typename T>
typedef value_type* NCollection_StdAllocator< T >::pointer

◆ reference

template<typename T>
typedef value_type& NCollection_StdAllocator< T >::reference

◆ size_type

template<typename T>
typedef size_t NCollection_StdAllocator< T >::size_type

◆ value_type

template<typename T>
typedef T NCollection_StdAllocator< T >::value_type

Constructor & Destructor Documentation

◆ NCollection_StdAllocator() [1/3]

template<typename T>
NCollection_StdAllocator< T >::NCollection_StdAllocator ( )
inline

Constructor.

Creates an object using default Open CASCADE allocation mechanism, i.e. which uses Standard::Allocate() and Standard::Free() underneath.

◆ NCollection_StdAllocator() [2/3]

template<typename T>
NCollection_StdAllocator< T >::NCollection_StdAllocator ( const Handle< NCollection_BaseAllocator > &  theAlloc)
inline

Constructor.

Saves theAlloc as an underlying allocator instance.

◆ NCollection_StdAllocator() [3/3]

template<typename T>
template<typename U >
NCollection_StdAllocator< T >::NCollection_StdAllocator ( const NCollection_StdAllocator< U > &  Y)
inline

Copy constructor.

Copies Allocator() from Y.

Member Function Documentation

◆ address() [1/2]

template<typename T>
pointer NCollection_StdAllocator< T >::address ( reference  x) const
inline

Returns an object address.

Returns &x.

◆ address() [2/2]

template<typename T>
const_pointer NCollection_StdAllocator< T >::address ( const_reference  x) const
inline

Returns an object address.

Returns &x.

◆ allocate()

template<typename T>
pointer NCollection_StdAllocator< T >::allocate ( size_type  n,
const void *  = 0 
)
inline

Allocates memory for n objects.

Uses underlying allocator to allocate memory.

◆ Allocator()

template<typename T>
const Handle< NCollection_BaseAllocator >& NCollection_StdAllocator< T >::Allocator ( ) const
inline

Returns an underlying NCollection_BaseAllocator instance.

Returns an object specified in the constructor.

◆ construct()

template<typename T>
void NCollection_StdAllocator< T >::construct ( pointer  p,
const_reference  val 
)
inline

Constructs an object.

Uses placement new operator and copy constructor to construct an object.

◆ deallocate()

template<typename T>
void NCollection_StdAllocator< T >::deallocate ( pointer  p,
size_type   
)
inline

Frees previously allocated memory.

Uses underlying allocator to deallocate memory.

◆ destroy()

template<typename T>
void NCollection_StdAllocator< T >::destroy ( pointer  p)
inline

Destroys the object.

Uses object destructor.

◆ max_size()

template<typename T>
size_type NCollection_StdAllocator< T >::max_size ( ) const
inline

Returns the largest value for which method allocate might succeed.

◆ operator=()

template<typename T>
template<typename U >
NCollection_StdAllocator& NCollection_StdAllocator< T >::operator= ( const NCollection_StdAllocator< U > &  Y)
inline

Assignment operator.

Field Documentation

◆ myAlloc

template<typename T>
Handle< NCollection_BaseAllocator > NCollection_StdAllocator< T >::myAlloc
protected

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