Section: 16.4.4.6 [allocator.requirements] Status: C++17 Submitter: Pablo Halpern Opened: 2014-11-11 Last modified: 2017-07-30
Priority: Not Prioritized
View other active issues in [allocator.requirements].
View all other issues in [allocator.requirements].
View all issues with C++17 status.
Discussion:
16.4.4.6 [allocator.requirements]/4 in the 2014-10 WP (N4140), says:
An allocator type
X
shall satisfy the requirements ofCopyConstructible
(17.6.3.1). TheX::pointer
,X::const_pointer
,X::void_pointer
, andX::const_void_pointer
types shall satisfy the requirements ofNullablePointer
(17.6.3.3). No constructor, comparison operator, copy operation, move operation, or swap operation on these types shall exit via an exception.X::pointer
andX::const_pointer
shall also satisfy the requirements for a random access iterator (24.2).
The words "these types" would normally apply only to the previous sentence only, i.e., only to the pointer types.
However, an alternative reading would be that the allocator constructors themselves cannot throw. The change to
the vector
and string
default constructors, making them unconditionally noexcept
depends
on this alternative reading.
noexcept
specifications for the string
and vector
default constructors
should be changed to make them conditional.
[2015-01-18 Library reflector vote]
The issue has been identified as Tentatively Ready based on six votes in favour.
Proposed resolution:
Change 16.4.4.6 [allocator.requirements] p4 as indicated:
An allocator type
X
shall satisfy the requirements ofCopyConstructible
(17.6.3.1). TheX::pointer
,X::const_pointer
,X::void_pointer
, andX::const_void_pointer
types shall satisfy the requirements ofNullablePointer
(17.6.3.3). No constructor, comparison operator, copy operation, move operation, or swap operation on these pointer types shall exit via an exception.X::pointer
andX::const_pointer
shall also satisfy the requirements for a random access iterator (24.2).
Change 27.4.3 [basic.string] following p5, class template basic_string
synopsis, as indicated:
(This change assumes that N4258 has been applied, as voted on in Urbana on 2014-11-08)
// 21.4.2, construct/copy/destroy: basic_string() noexcept(noexcept(Allocator())) : basic_string(Allocator()) { }
An alternative formulation of the above would be:
// 21.4.2, construct/copy/destroy: basic_string() noexcept(is_nothrow_default_constructible<Allocator>{}) : basic_string(Allocator()) { }
Change 23.3.11.1 [vector.overview] following p2, class template vector
synopsis, as indicated:
(This change assumes that N4258 has been applied, as voted on in Urbana on 2014-11-08)
// 23.3.6.2, construct/copy/destroy: vector() noexcept(noexcept(Allocator())) : vector(Allocator()) { }
An alternative formulation of the above would be:
// 23.3.6.2, construct/copy/destroy: vector() noexcept(is_nothrow_default_constructible<Allocator>{}) : vector(Allocator()) { }