Nope. It uses this:
inline char*
uninitialized_copy(const char* __first,
const char* __last,
char* __result)
{
memmove(__result, __first, __last - __first);
return __result + (__last - __first);
}
Well, yes. That's the specialization for uninitialized_copy
when you know you're copying arrays of char. The real
question is whether vector can determine if it's okay to
use it. I just spent a few minutes staring at stl/_vector.h,
which is the SGI STL code common to libstdc++, STLPort, and
several other libraries. If I read it correctly, then it
does indeed end up performing a single memmove call when
assigning an entire vector. But the chain of logic is not
all that easy to follow. (And unfortunately, the code also
seems to perform this optimization even for a vector with a
user-supplied allocator. That rules out all sorts of smart
allocators once touted as an advantage of having allocators
separate from containers. I suspect the C++ Standard allows
this simplification, but it encourages implementors to do
better. We do, and we still do the single memmove when it's
completely safe to do so.)
You mean "yes it is?" The answer is that it may or may not be. Please
see my recent reply to OM.
Sorry, the answer was far from clear. It is true that the type of
the allocator is part of the type of the container. An
implementation that supports only memoryless allocators (which
is permitted, though not encouraged, as I mentioned above)
can construct an allocator object every time it needs it, and
hence need not store a copy of the allocator within the container
object. Implicit in this simplification is the assumption that
such construction is weightless, or at least cheap, which may
or may not be true even for memoryless allocators.
I stand corrected.
Do you mean to tell me that static methods are not allowed in
allocators? Why would that be?
I didn't say that. What I said was the prototypical allocator,
supplied in the library as template class allocator, has no
static methods. The entire user interface is in terms of calls
on non-static member functions. Hence, you have to create an
allocator object to do all the things that allocators do for
you. You're free to add static functions, but they're not part
of the defined interface. Any container you write that makes
use of them won't conform to the rules for extending STL
containers.
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com