Open CASCADE Technology 6.6.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 () 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_BaseAllocatormyAlloc

Detailed Description

template<typename T>
class NCollection_StdAllocator< T >

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);

Member Typedef Documentation

template<typename T >
typedef const value_type* NCollection_StdAllocator< T >::const_pointer
template<typename T >
typedef const value_type& NCollection_StdAllocator< T >::const_reference
template<typename T >
typedef ptrdiff_t NCollection_StdAllocator< T >::difference_type
template<typename T >
typedef value_type* NCollection_StdAllocator< T >::pointer
template<typename T >
typedef value_type& NCollection_StdAllocator< T >::reference
template<typename T >
typedef size_t NCollection_StdAllocator< T >::size_type
template<typename T >
typedef T NCollection_StdAllocator< T >::value_type

Constructor & Destructor Documentation

template<typename T >
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.

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

Saves theAlloc as an underlying allocator instance.

template<typename T >
NCollection_StdAllocator< T >::NCollection_StdAllocator ( const NCollection_StdAllocator< T > &  X) throw () [inline]

Copies Allocator() from X.

template<typename T >
NCollection_StdAllocator< T >::~NCollection_StdAllocator ( ) throw () [inline]

Empty implementation.

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

Copies Allocator() from Y.


Member Function Documentation

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

Returns &x.

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

Returns &x.

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

Uses underlying allocator to allocate memory.

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

Returns an object specified in the constructor.

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

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

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

Uses underlying allocator to deallocate memory.

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

Uses object destructor.

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

Field Documentation

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

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines