Title
What does allocate(0) return?
Status
tc1
Section
[allocator.requirements]
Submitter
Matt Austern

Created on 1999-11-19.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

A key to understanding this issue is that the ultimate use of allocate() is to construct an iterator, and that iterator for zero length sequences must be the container's past-the-end representation. Since this already implies special case code, it would be over-specification to mandate the return value.

Date: 2010-10-21.18:28:33

Proposed resolution:

Add a note to the allocate row of Table 32: "[Note: If n == 0, the return value is unspecified. --end note]"

Date: 1999-11-19.00:00:00

Suppose that A is a class that conforms to the Allocator requirements of Table 32, and a is an object of class A What should be the return value of a.allocate(0)? Three reasonable possibilities: forbid the argument 0, return a null pointer, or require that the return value be a unique non-null pointer.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg1833
2010-10-21 18:28:33adminsetmessages: + msg1832
1999-11-19 00:00:00admincreate