Re: std::allocator::address
ivan@0x4849.net ha scritto:
The standard section 20.4.1.1/1 [lib.allocator.members]
Defines that the std::allocator should have a member with the following
signature:
pointer address(reference x) const;
It then says that this member function should return the address of the
parameter x.
I am not seeing what is the point of having such a function.
Can someone explain the reason for it to exist?
As far as I understand, allocators were initially an attempt to
introduce multiple memory models on some specific architectures. For
example, old 80x86 CPUs had "near" and "far" pointers and you needed
care when mixing them. Eventually, C++ chose the single memory model
approach, so a lot of allocators methods are now just useless legacy.
http://www.sgi.com/tech/stl/Allocators.html states this (notice, in
particular, the last sentence):
"Note also that allocators do not attempt to encapsulate multiple memory
models. The C++ language only defines a single memory model (the
difference of two pointers, for example, is always ptrdiff_t), and this
memory model is the only one that allocators support. /This is a major
change from the definition of allocators in the original STL/."
HTH,
Ganesh
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]