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

3957. §[container.alloc.reqmts] The value category of v should be claimed

Section: 23.2.2.5 [container.alloc.reqmts] Status: WP Submitter: jim x Opened: 2023-07-10 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [container.alloc.reqmts].

View all issues with WP status.

Discussion:

23.2.2.5 [container.alloc.reqmts] p2 says:

[…] an expression v of type T or const T, […]

Then 23.2.2.5 [container.alloc.reqmts] bullet (2.4) says:

T is Cpp17CopyInsertable into X means that, in addition to T being Cpp17MoveInsertable into X, the following expression is well-formed:

allocator_traits<A>::construct(m, p, v)

So, what is the value category of the expression v? We didn't explicitly phrase the wording. The intent may be that the value category of v is any defined value category in 7.2.1 [basic.lval], however, the intent is not clear in the current wording. Maybe, we can say:

[…] the following expression is well-formed:

allocator_traits<A>::construct(m, p, v)

for v of any value category.

which can make the intent meaning clearer.

[2023-10-27; Reflector poll]

Set status to Tentatively Ready after five votes in favour during reflector poll.

[2023-11-11 Approved at November 2023 meeting in Kona. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4950.

  1. Modify 23.2.2.5 [container.alloc.reqmts] as indicated:

    -2- Given an allocator type A and given a container type X having a value_type identical to T and an allocator_type identical to allocator_traits<A>::rebind_alloc<T> and given an lvalue m of type A, a pointer p of type T*, an expression v that denotes an lvalue of type T or const T or an rvalue of type const T, and an rvalue rv of type T, the following terms are defined. […]

    1. […]

    2. (2.3) — T is Cpp17MoveInsertable into X means that the following expression is well-formed:

      allocator_traits<A>::construct(m, p, rv)
      

      and its evaluation causes the following postcondition to hold: The value of *p is equivalent to the value of rv before the evaluation.

      [Note 1: rv remains a valid object. Its state is unspecified — end note]

    3. (2.4) — T is Cpp17CopyInsertable into X means that, in addition to T being Cpp17MoveInsertable into X, the following expression is well-formed:

      allocator_traits<A>::construct(m, p, v)
      

      and its evaluation causes the following postcondition to hold: The value of v is unchanged and is equivalent to *p.

    4. […]