Re: construct() and destroy() no longer in standard?
carl.seleborg@gmail.com ha scritto:
Hi all,
According to SGI's documentation of the STL, std::construct() and
std::destroy() are no longer part of the C++ standard :
"The construct/destroy algorithms are no longer part of the C++
standard; they were present in early drafts, and they are retained in
this implementation for backward compatibility."
Is this true?
Yes it is true, there are no such algorithms in the standard. However
the allocators have been added construct and destroy methods, which
could be used as a replacement.
If so, how do std::vector and std::dequeue construct its
elements then?
AFAIK, there is no requirement upon std::vector and std::deque about how
elements are created/destroyed, as long as the observable effect is the
expected one. They are not even required to use the allocator
construct/destroy methods I mentioned before.
I would expect a std::vector and std::deque to use uninitialized_fill
and uninitialized_copy to construct and copy objects. I find it a bit
unfortunate that this expectation is not mandated because it might have
provided the user with a nice opportunity for optimization.
Just my 2 eurocent,
Ganesh
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]