Movatterモバイル変換


[0]ホーム

URL:



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

2147. Unclear hint type inAllocator'sallocate function

Section: 16.4.4.6[allocator.requirements]Status:C++14Submitter: Daniel KrüglerOpened: 2012-03-05Last modified: 2016-01-28

Priority:Not Prioritized

View otheractive issues in [allocator.requirements].

View all otherissues in [allocator.requirements].

View all issues withC++14 status.

Discussion:

According to Table 28 — "Allocator requirements", the expression

a.allocate(n, u)

expects as second argument a valueu that is described in Table 27 as:

a value of typeYY::const_pointer obtained by callingYY::allocate, or elsenullptr.

This description leaves it open, whether or whether not a value of typeYY::const_void_pointer isvalid or not. The corresponding wording in C++03 is nearly the same, but in C++03 there did not exist the concept ofa generalvoid_pointer for allocators. There is some evidence for support of void pointers becausethe generalallocator_traits template declares

static pointer allocate(Alloc& a, size_type n, const_void_pointer hint);

and the corresponding function forstd::allocator<T> is declared as:

pointer allocate(size_type, allocator<void>::const_pointer hint = 0);

As an additional minor wording glitch (especially when comparing with theNullablePointer requirements imposed onconst_pointer andconst_void_pointer), the wording seems to exclude lvalues of typestd::nullptr_t, which looks like an unwanted artifact to me.

[2012-10 Portland: Move to Ready ]

No strong feeling that this is a big issue, but consensus that the proposed resolution is strictlybetter than the current wording, so move to Ready.

[2013-04-20 Bristol]

Proposed resolution:

This wording is relative to N3376.

  1. Change Table 27 — "Descriptive variable definitions" in 16.4.4.6[allocator.requirements]:

    Table 27 — Descriptive variable definitions
    VariableDefinition
    ua value of typeYY::const_pointer obtained by callingYY::allocate, or elsenullptrXX::const_void_pointer obtained by conversion from a result value ofYY::allocate, or else a value of type (possibly const)std::nullptr_t.

[8]ページ先頭

©2009-2026 Movatter.jp