A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/LWG/issue199 below:

Issue 199: What does allocate(0) return?

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

199. What does allocate(0) return?

Section: 16.4.4.6 [allocator.requirements] Status: TC1 Submitter: Matt Austern Opened: 1999-11-19 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [allocator.requirements].

View all other issues in [allocator.requirements].

View all issues with TC1 status.

Discussion:

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.

Proposed resolution:

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

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4