Title
Container requirements and placement new
Status
dup
Section
[container.requirements]
Submitter
Herb Sutter

Created on 2004-08-01.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Duplicate: 580

Date: 2010-10-21.18:28:33

[ Lillehammer: A container will definitely never use this overridden operator new, but whether it will fail to compile is unclear from the standard. Are containers supposed to use qualified or unqualified placement new? 20.4.1.1 is somewhat relevant, but the standard doesn't make it completely clear whether containers have to use Allocator::construct(). If containers don't use it, the details of how containers use placement new are unspecified. That is the real bug, but it needs to be fixed as part of the allocator overhaul. Weak support that the eventual solution should make this code well formed. ]

Date: 2004-08-01.00:00:00

Nothing in the standard appears to make this program ill-formed:

  struct C {
    void* operator new( size_t s ) { return ::operator new( s ); }
    // NOTE: this hides in-place and nothrow new
  };

  int main() {
    vector<C> v;
    v.push_back( C() );
  }

Is that intentional? We should clarify whether or not we intended to require containers to support types that define their own special versions of operator new.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2789
2010-10-21 18:28:33adminsetmessages: + msg2788
2004-08-01 00:00:00admincreate