Open CASCADE Technology 6.6.0
|
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_type * | pointer |
typedef const value_type * | const_pointer |
typedef value_type & | reference |
typedef const value_type & | const_reference |
typedef size_t | size_type |
typedef ptrdiff_t | difference_type |
Public Member Functions | |
NCollection_StdAllocator () throw () | |
Constructor. | |
NCollection_StdAllocator (const Handle< NCollection_BaseAllocator > &theAlloc) throw () | |
Constructor. | |
NCollection_StdAllocator (const NCollection_StdAllocator &X) throw () | |
Constructor. | |
~NCollection_StdAllocator () throw () | |
Destructor. | |
template<typename U > | |
NCollection_StdAllocator (const NCollection_StdAllocator< U > &Y) throw () | |
Constructor. | |
pointer | address (reference x) const |
Returns an object address. | |
const_pointer | address (const_reference x) const |
Returns an object address. | |
pointer | allocate (size_type n, const void *=0) |
Allocates memory for n objects. | |
void | deallocate (pointer p, size_type) |
Frees previously allocated memory. | |
size_type | max_size () const throw () |
Returns the largest value for which method allocate might succeed. | |
void | construct (pointer p, const_reference val) |
Constructs an object. | |
void | destroy (pointer p) |
Destroys the object. | |
const Handle < NCollection_BaseAllocator > & | Allocator () const |
Returns an underlying NCollection_BaseAllocator instance. | |
Protected Attributes | |
Handle< NCollection_BaseAllocator > | myAlloc |
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:
Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator(); NCollection_StdAllocator<TopoDS_Shape> aSAlloc (anIncAlloc); std::list<TopoDS_Shape, NCollection_StdAllocator<TopoDS_Shape> > aL (aSAlloc); TopoDS_Solid aSolid = BRepPrimAPI_MakeBox (10., 20., 30.); aL.push_back (aSolid);
typedef const value_type* NCollection_StdAllocator< T >::const_pointer |
typedef const value_type& NCollection_StdAllocator< T >::const_reference |
typedef ptrdiff_t NCollection_StdAllocator< T >::difference_type |
typedef value_type* NCollection_StdAllocator< T >::pointer |
typedef value_type& NCollection_StdAllocator< T >::reference |
typedef size_t NCollection_StdAllocator< T >::size_type |
typedef T NCollection_StdAllocator< T >::value_type |
NCollection_StdAllocator< T >::NCollection_StdAllocator | ( | ) | throw () [inline] |
Creates an object using default Open CASCADE allocation mechanism, i.e. which uses Standard::Allocate() and Standard::Free() underneath.
NCollection_StdAllocator< T >::NCollection_StdAllocator | ( | const Handle< NCollection_BaseAllocator > & | theAlloc | ) | throw () [inline] |
Saves theAlloc as an underlying allocator instance.
NCollection_StdAllocator< T >::NCollection_StdAllocator | ( | const NCollection_StdAllocator< T > & | X | ) | throw () [inline] |
Copies Allocator() from X.
NCollection_StdAllocator< T >::~NCollection_StdAllocator | ( | ) | throw () [inline] |
Empty implementation.
NCollection_StdAllocator< T >::NCollection_StdAllocator | ( | const NCollection_StdAllocator< U > & | Y | ) | throw () [inline] |
Copies Allocator() from Y.
pointer NCollection_StdAllocator< T >::address | ( | reference | x | ) | const [inline] |
Returns &x.
const_pointer NCollection_StdAllocator< T >::address | ( | const_reference | x | ) | const [inline] |
Returns &x.
pointer NCollection_StdAllocator< T >::allocate | ( | size_type | n, |
const void * | = 0 |
||
) | [inline] |
Uses underlying allocator to allocate memory.
const Handle< NCollection_BaseAllocator >& NCollection_StdAllocator< T >::Allocator | ( | ) | const [inline] |
Returns an object specified in the constructor.
void NCollection_StdAllocator< T >::construct | ( | pointer | p, |
const_reference | val | ||
) | [inline] |
Uses placement new operator and copy constructor to construct an object.
void NCollection_StdAllocator< T >::deallocate | ( | pointer | p, |
size_type | |||
) | [inline] |
Uses underlying allocator to deallocate memory.
void NCollection_StdAllocator< T >::destroy | ( | pointer | p | ) | [inline] |
Uses object destructor.
size_type NCollection_StdAllocator< T >::max_size | ( | ) | const throw () [inline] |
Handle< NCollection_BaseAllocator > NCollection_StdAllocator< T >::myAlloc [protected] |