Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.9.8
Gecode::region_allocator< T > Struct Template Reference

Allocator that allocates memory from a region. More...

#include <allocators.hpp>

Classes

struct  rebind
 Rebinding helper (returns the type of a similar allocator for type U). More...
 

Public Types

typedef T value_type
 Type of objects the allocator creates. This is identical to T.
 
typedef size_t size_type
 Type that can represent the size of the largest object.
 
typedef ptrdiff_t difference_type
 Type that can represent the difference between any two pointers.
 
typedef T * pointer
 Type of pointers returned by the allocator.
 
typedef T const * const_pointer
 Const version of pointer.
 
typedef T & reference
 Non-const reference to T.
 
typedef T const & const_reference
 Const reference to T.
 

Public Member Functions

 region_allocator (Region &region) throw ()
 Construction.
 
 region_allocator (region_allocator const &al) throw ()
 Copy construction.
 
template<class U >
 region_allocator (region_allocator< U > const &al) throw ()
 Copy from other instantiation.
 
pointer address (reference x) const
 Convert a reference x to a pointer.
 
const_pointer address (const_reference x) const
 Convert a const reference x to a const pointer.
 
size_type max_size (void) const throw ()
 Returns the largest size for which a call to allocate might succeed.
 
pointer allocate (size_type count)
 Allocates storage.
 
pointer allocate (size_type count, const void *const hint)
 Allocates storage.
 
void deallocate (pointer p, size_type count)
 Deallocates storage.
 
void construct (pointer element, const_reference t)
 Constructs an object.
 
void destroy (pointer element)
 Calls the destructor on the object pointed to by element.
 

Public Attributes

Region & region
 The region that we allocate objects from.
 

Detailed Description

template<class T>
struct Gecode::region_allocator< T >

Allocator that allocates memory from a region.

Note that this allocator may be used to construct dynamic data structures that allocate memory from the region, or even reside in the region as a whole.

Definition at line 338 of file allocators.hpp.

Member Typedef Documentation

◆ value_type

template<class T >
typedef T Gecode::region_allocator< T >::value_type

Type of objects the allocator creates. This is identical to T.

Definition at line 340 of file allocators.hpp.

◆ size_type

template<class T >
typedef size_t Gecode::region_allocator< T >::size_type

Type that can represent the size of the largest object.

Definition at line 342 of file allocators.hpp.

◆ difference_type

template<class T >
typedef ptrdiff_t Gecode::region_allocator< T >::difference_type

Type that can represent the difference between any two pointers.

Definition at line 344 of file allocators.hpp.

◆ pointer

template<class T >
typedef T* Gecode::region_allocator< T >::pointer

Type of pointers returned by the allocator.

Definition at line 346 of file allocators.hpp.

◆ const_pointer

template<class T >
typedef T const* Gecode::region_allocator< T >::const_pointer

Const version of pointer.

Definition at line 348 of file allocators.hpp.

◆ reference

template<class T >
typedef T& Gecode::region_allocator< T >::reference

Non-const reference to T.

Definition at line 350 of file allocators.hpp.

◆ const_reference

template<class T >
typedef T const& Gecode::region_allocator< T >::const_reference

Const reference to T.

Definition at line 352 of file allocators.hpp.

Constructor & Destructor Documentation

◆ region_allocator() [1/3]

template<class T >
Gecode::region_allocator< T >::region_allocator ( Region &  region)
throw (
)
inline

Construction.

Parameters
regionThe region to allocate objects from.

Definition at line 367 of file allocators.hpp.

◆ region_allocator() [2/3]

template<class T >
Gecode::region_allocator< T >::region_allocator ( region_allocator< T > const &  al)
throw (
)
inline

Copy construction.

Parameters
alThe allocator to copy.

Definition at line 373 of file allocators.hpp.

◆ region_allocator() [3/3]

template<class T >
template<class U >
Gecode::region_allocator< T >::region_allocator ( region_allocator< U > const &  al)
throw (
)
inline

Copy from other instantiation.

Parameters
alThe source allocator.

Definition at line 380 of file allocators.hpp.

Member Function Documentation

◆ address() [1/2]

template<class T >
pointer Gecode::region_allocator< T >::address ( reference  x) const
inline

Convert a reference x to a pointer.

Definition at line 384 of file allocators.hpp.

◆ address() [2/2]

template<class T >
const_pointer Gecode::region_allocator< T >::address ( const_reference  x) const
inline

Convert a const reference x to a const pointer.

Definition at line 386 of file allocators.hpp.

◆ max_size()

template<class T >
size_type Gecode::region_allocator< T >::max_size ( void  ) const
throw (
)
inline

Returns the largest size for which a call to allocate might succeed.

Definition at line 388 of file allocators.hpp.

◆ allocate() [1/2]

template<class T >
pointer Gecode::region_allocator< T >::allocate ( size_type  count)
inline

Allocates storage.

Returns a pointer to the first element in a block of storage count*sizeof(T) bytes in size. The block is aligned appropriately for objects of type T. Throws the exception bad_alloc if the storage is unavailable.

Definition at line 401 of file allocators.hpp.

◆ allocate() [2/2]

template<class T >
pointer Gecode::region_allocator< T >::allocate ( size_type  count,
const void *const  hint 
)
inline

Allocates storage.

Returns a pointer to the first element in a block of storage count*sizeof(T) bytes in size. The block is aligned appropriately for objects of type T. Throws the exception bad_alloc if the storage is unavailable.

The (unused) parameter could be used as an allocation hint, but this allocator ignores it.

Definition at line 416 of file allocators.hpp.

◆ deallocate()

template<class T >
void Gecode::region_allocator< T >::deallocate ( pointer  p,
size_type  count 
)
inline

Deallocates storage.

Deallocates storage obtained by a call to allocate() with arguments count and p. Note that region allocator never actually deallocates memory (so this function does nothing); the memory is released when the region is destroyed.

Definition at line 429 of file allocators.hpp.

◆ construct()

template<class T >
void Gecode::region_allocator< T >::construct ( pointer  element,
const_reference  t 
)
inline

Constructs an object.

Constructs an object of type T with the initial value of t at the location specified by element. This function calls the placement new() operator.

Definition at line 440 of file allocators.hpp.

◆ destroy()

template<class T >
void Gecode::region_allocator< T >::destroy ( pointer  element)
inline

Calls the destructor on the object pointed to by element.

Definition at line 445 of file allocators.hpp.

Member Data Documentation

◆ region

template<class T >
Region& Gecode::region_allocator< T >::region

The region that we allocate objects from.

Definition at line 361 of file allocators.hpp.


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