value_type | Typedef on allocators |
reference | Typedef on allocators |
const_reference | Typedef on allocators |
pointer | Typedef on allocators |
const_pointer | Typedef on allocators |
size_type | Typedef on allocators |
difference_type | Typedef on allocators |
In the following table, assume X is an allocator class for objects of type T, a is a value of X, n is of type X::size_type, p is of type X::pointer, r is of type X::reference and s is of type X::const_reference.
X () | Constructor on allocators |
pointer address (reference r) | Method on allocators |
const_pointer const_address (const_reference s) | Method on allocators |
pointer allocate (size_type n) | Method on allocators |
deallocate (pointer p) | Method on allocators |
void construct (pointer p, value_type a) | Method on allocators |
void destroy (pointer p) | Method on allocators |
size_type init_page_size () | Method on allocators |
size_type max_size () | Method on allocators |
All the operations on the allocators are expected to be amortized
constant time.
Expression | Return type | Assertion/note pre/post-condition |
X::value_type | T | |
X::reference | lvalue of T | |
X::const_reference | const lvalue of T | |
X::pointer | pointer to T type | the result of
operator*
of values of
X::pointer
is of reference. |
X::const_pointer | pointer to const T type | the result of
operator*
of values of
X::const_pointer
is of const_reference;
it is
the same type of pointer as X::pointer,
in particular,
sizeof(X::const_pointer) == sizeof(X::pointer).
|
X::size_type | unsigned integral type | the type that can represent the size of the largest object in the memory model. |
X::difference_type | signed integral type | the type that can represent the difference between any two pointers in the memory model. |
X a; | note: a destructor is assumed. | |
a.address(r) | pointer | *(a.address(r)) == r. |
a.const_address(s) | const_pointer | *(a.address(s)) == s. |
a.allocate(n) | X::pointer | memory is allocated for n objects of type
T but objects are not constructed.
allocate may
raise an appropriate exception.
|
a.deallocate(p) | result is not used | all the objects in the area pointed by p
should be destroyed prior to the call of the deallocate.
|
construct(p, a) | void | post:
*p == a. |
destroy(p) | void | the value pointed by
p is destroyed.
|
a.init_page_size() | X::size_type | the returned value is the optimal value for an initial
buffer size of the given type. It is assumed that if
k is returned by
init_page_size, t
is the construction time for
T, and
u is the time that it takes to do
allocate(k),
then k
\times t
is much greater
than u. |
a.max_size() | X::size_type | the largest positive value of
X::difference_type |
Pointer belongs to the category of mutable random access iterators referring to T. const_pointer belongs to the category of constant random access iterators referring to T. There is a conversion defined from pointer to const_pointer.
For any allocator template Alloc there is a specialization for type void. Alloc<void> has only constructor, destructor, and Alloc<void>::pointer defined. Conversions are defined from any instance of Alloc<T>::pointer into Alloc<void>::pointer and back so that for any p, p == Alloc<T>::pointer(Alloc<void>::pointer(p)).
|
|