Title
Are containers required to use their 'pointer' type internally?
Status
c++17
Section
[container.requirements]
Submitter
Jonathan Wakely

Created on 2013-05-14.00:00:00 last changed 89 months ago

Messages

Date: 2016-08-05.16:29:09

[ Drafting notes: if people prefer this to be normative, strip the "Note" markups. ]

Modify [container.requirements.general]/8 as indicated:

Unless otherwise specified, all containers defined in this clause obtain memory using an allocator (see [allocator.requirements]). [Note: In particular, containers and iterators do not store references to allocated elements other than through the allocator's pointer type, i.e., as objects of type P or pointer_traits<P>::template rebind<unspecified>, where P is allocator_traits<allocator_type>::pointer. — end note]

Date: 2016-08-03.12:32:27

Proposed resolution:

This wording is relative to N4606.

Date: 2016-08-06.20:44:18

[ 2016-08 Chicago ]

Tues PM: General agreement on direction, Alisdair and Billy to update wording

Fri AM: Moved to Tentatively Ready

Date: 2016-08-02.16:09:45

[ 2016-08, Zhihao comments ]

The pointer types are not exposed in the container interface, and we consider that the memory allocation constraints "all containers defined in this clause obtain memory using an allocator" already implies the reasonable expectation. We propose the fix as non-normative.

Date: 2014-06-15.00:00:00

[ 2014-06-12, Jonathan comments ]

This issue is basically the same issue as LWG 1521, which agrees it's an issue, to be dealt with in the future, so I request that 2261 not be closed as a dup unless we reopen 1521.

Date: 2013-05-14.00:00:00

Is a container C only supposed to refer to allocated memory (blocks of contiguous storage, nodes, etc.) through objects of type C::pointer rather than C::value_type*?

I don't see anything explicitly requiring this, so a container could immediately convert the result of get_allocator().allocate(1) to a built-in pointer of type value_type* and only deal with the built-in pointer until it needs to deallocate it again, but that removes most of the benefit of allowing allocators to use custom pointer types.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-08-06 20:44:18adminsetstatus: new -> ready
2016-08-03 12:32:27adminsetmessages: + msg8354
2016-08-02 16:09:45adminsetmessages: + msg8317
2016-08-02 16:09:45adminsetmessages: + msg8316
2016-08-02 16:09:45adminsetmessages: + msg8315
2014-06-12 18:49:29adminsetmessages: + msg7024
2013-05-14 00:00:00admincreate