Title
Allocator::construct is too limiting
Status
nad
Section
[allocator.requirements]
Submitter
Dhruv Matani

Created on 2004-10-17.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

NAD. STL uses copying all the time, and making it possible for allocators to construct noncopyable objects is useless in the absence of corresponding container changes. We might consider this as part of a larger redesign of STL.

Date: 2004-10-17.00:00:00

The standard's version of allocator::construct(pointer, const_reference) severely limits what you can construct using this function. Say you can construct a socket from a file descriptor. Now, using this syntax, I first have to manually construct a socket from the fd, and then pass the constructed socket to the construct() function so it will just to an uninitialized copy of the socket I manually constructed. Now it may not always be possible to copy construct a socket eh! So, I feel that the changes should go in the allocator::construct(), making it:

    template<typename T>
    struct allocator{
      template<typename T1>
      void construct(pointer T1 const& rt1);
    };

Now, the ctor of the class T which matches the one that takes a T1 can be called! Doesn't that sound great?

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2821
2004-10-17 00:00:00admincreate