Title
purpose of hint to allocator::allocate()
Status
cd1
Section
[allocator.members]
Submitter
Martin Sebor

Created on 2006-05-17.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Remove the requirement in 20.6.1.1, p4 that the hint be a value previously returned from allocate(). Specifically, change the paragraph as follows:

Requires: hint either 0 or previously obtained from member allocate and not yet passed to member deallocate. The value hint may be used by an implementation to help improve performance 223). [Note: The value hint may be used by an implementation to help improve performance. -- end note]

[Footnote: 223)In a container member function, the address of an adjacent element is often a good choice to pass for this argument.

Date: 2006-05-17.00:00:00

The description of the allocator member function allocate() requires that the hint argument be either 0 or a value previously returned from allocate(). Footnote 227 further suggests that containers may pass the address of an adjacent element as this argument.

I believe that either the footnote is wrong or the normative requirement that the argument be a value previously returned from a call to allocate() is wrong. The latter is supported by the resolution to issue 20-004 proposed in c++std-lib-3736 by Nathan Myers. In addition, the hint is an ordinary void* and not the pointer type returned by allocate(), with the two types potentially being incompatible and the requirement impossible to satisfy.

See also c++std-lib-14323 for some more context on where this came up (again).

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3106
2006-05-17 00:00:00admincreate