Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofTC1 status.

199. What doesallocate(0) return?

Section: 16.4.4.6[allocator.requirements]Status:TC1Submitter: Matt AusternOpened: 1999-11-19Last modified: 2016-01-28

Priority:Not Prioritized

View otheractive issues in [allocator.requirements].

View all otherissues in [allocator.requirements].

View all issues withTC1 status.

Discussion:

Suppose thatA is a class that conforms to theAllocator requirements of Table 32, anda is anobject of classA What should be the returnvalue ofa.allocate(0)? Three reasonablepossibilities: forbid the argument0, returna null pointer, or require that the return value be aunique non-null pointer.

Proposed resolution:

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

Rationale:

A key to understanding this issue is that the ultimate use ofallocate() is to construct an iterator, and that iterator for zerolength sequences must be the container's past-the-endrepresentation. Since this already implies special case code, itwould be over-specification to mandate the return value.


[8]ページ先頭

©2009-2026 Movatter.jp