Gianni said:
I don't have that book, so I don't know what you're referrinf to.
Things about class alocator in <memory> that uses operator new() by
default, and how to create your own ones:
"Implementers of containers often allocate() and deallocate() objects
one at a time. For a naive implementation of allocate(), this implies
lots of calls of operator new , and not all implementations of operator
new are efficient when used like that. As an example of a user-defined
allocator, I present a scheme for using pools of fixed-sized pieces of
memory from which the allocator can allocate() more efficiently than can
a conventional and more general operator new().
I happen to have a pool allocator that does approximately the right
thing, but it has the wrong interface (because it was designed years
before allocators were invented). This Pool class implements the notion
of a pool of fixed-sized elements from which a user can do fast
allocations and deallocations. It is a low-level type that deals with
memory directly and worries about alignment:"
Some other facilities:
"19.4.4 Uninitialized Memory
In addition to the standard allocator , the <memory > header provides a
few functions for dealing with uninitialized memory. They share the
dangerous and occasionally essential property of using a type name T to
refer to space sufficient to hold an object of type T rather than to a
properly constructed object of type T .
The library provides three ways to copy values into uninitialized space:"
and it talks about uninitialized_copy, uninitialized_fill and uninitial
ized_fill_n.
Then, other facilities are mentioned like
"Algorithms often require temporary space to perform acceptably. Often,
such temporary space is best allocated in one operation but not
initialized until a particular location is actually needed.
Consequently, the library provides a pair of functions for allocating
and deallocating uninitialized space:
template <class T> pair <T *,ptrdiff_t > get_temporary_buffer(ptrdiff_t
); // allocate, don’t initialize
template <class T> void return_temporary_buffer(T *); // deallocate,
don’t destroy
A get_temporary_buffer<X >(n) operation tries to allocate space for n or
more objects of type X .
If it succeeds in allocating some memory, it returns a pointer to the
first uninitialized space and the number of objects of type X that will
fit into that space; otherwise, the second value of the pair is zero.
The idea is that a system may keep a number of fixed-sized buffers ready
for fast allocation so that requesting space for n objects may yield
space for more than n . It may also yield less, however, so one way of
using get_temporary_buffer() is to optimistically ask for a lot and then
use what happens to be available."
And other stuff, it is an entire chapter.