2081. Allocator requirements should include CopyConstructible

Section: [allocator.requirements] Status: C++14 Submitter: Jonathan Wakely Opened: 2011-08-30 Last modified: 2016-02-10

Priority: Not Prioritized

View other active issues in [allocator.requirements].

View all other issues in [allocator.requirements].

View all issues with C++14 status.


As discussed in c++std-lib-31054 and c++std-lib-31059, the Allocator requirements implicitly require CopyConstructible because a.select_on_container_copy_construction() and container.get_allocator() both return a copy by value, but the requirement is not stated explicitly anywhere.

In order to clarify that allocators cannot have 'explicit' copy constructors, the requirements should include CopyConstructible.

[2012, Kona]

Move to Ready.

[2012, Portland: applied to WP]

Proposed resolution:

This wording is relative to the FDIS.

  1. Change Table 28 — Allocator requirements in [allocator.requirements]:

    Table 28 — Allocator requirements
    Expression Return type Assertion/note pre-/post-condition Default
    X a1(a);
    X a1 = a;
    Shall not exit via an exception.
    post: a1 == a
    X a1(move(a));
    X a1 = move(a);
    Shall not exit via an exception.
    post: a1 equals the prior value
    of a.
  2. Change [allocator.requirements] paragraph 4:

    An allocator type X shall satisfy the requirements of CopyConstructible ( [utility.arg.requirements]). The X::pointer, X::const_pointer, X::void_pointer, and X::const_void_pointer types shall satisfy the requirements of NullablePointer ( [nullablepointer.requirements]). No constructor, comparison operator, copy operation, move operation, or swap operation on these types shall exit via an exception. X::pointer and X::const_pointer shall also satisfy the requirements for a random access iterator (27.2 [iterator.requirements]).