2260. Missing requirement for Allocator::pointer

Section: 20.5.3.5 [allocator.requirements] Status: C++17 Submitter: Jonathan Wakely Opened: 2013-05-14 Last modified: 2017-07-30

Priority: 3

View other active issues in [allocator.requirements].

View all other issues in [allocator.requirements].

View all issues with C++17 status.

Discussion:

For an allocator A<T> which defines A<T>::pointer to a class type, i.e. not T*, I see no requirement that A<T>::pointer is convertible to A<U>::pointer, even if T* is convertible to U*. Such conversions are needed in containers to convert from e.g. ListNodeBase* to ListNode<T>*.

The obvious way to do such conversions appears to be pointer_traits::pointer_to(), but that's ill-formed if the static member function A<T>::pointer::pointer_to() doesn't exist and the allocator requirements don't mention that function, so you need to cast A<T>::pointer to A<T>::void_pointer then cast that to A<U>::pointer.

Is converting via void_pointer really intended, or are we missing a requirement that pointer_traits<A<T>::pointer>::pointer_to() be well-formed?

Proposed resolution:

Add to the Allocator requirements table the following requirement:

The expression pointer_traits<XX::pointer>::pointer_to(r) is well-defined.

[2013-09 Chicago]

Pablo to come back with proposed wording

[2015-07 Telecon]

Marshall to ping Pablo for proposed wording and disable current wording.

Previous resolution [SUPERSEDED]:
  1. Edit Table 28 as indicated:

    Table 28 — Allocator requirements (continued)
    Expression Return type Assertion/note pre-/post-condition Default
    static_cast<X::const_pointer>(z) X::const_pointer static_cast<X::const_pointer>(z) == q  
    pointer_traits<X::pointer>::pointer_to(r) X::pointer    

[2016-11-12, Issaquah]

This is related to 1521.

Sat PM: Restore original P/R and move to tentatively ready.

Proposed resolution:

  1. Edit Table 28 as indicated:

    Table 28 — Allocator requirements (continued)
    Expression Return type Assertion/note pre-/post-condition Default
    static_cast<X::const_pointer>(z) X::const_pointer static_cast<X::const_pointer>(z) == q  
    pointer_traits<X::pointer>::pointer_to(r) X::pointer