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

2151. basic_string<>::swap semantics ignore allocators

Section: 23.4.3.2 [string.require] Status: Resolved Submitter: Robert Shearer Opened: 2012-04-13 Last modified: 2018-11-25

Priority: 3

View all other issues in [string.require].

View all issues with Resolved status.

Discussion:

In C++11, basic_string is not described as a "container", and is not governed by the allocator-aware container semantics described in sub-clause 24.2 [container.requirements]; as a result, and requirements or contracts for the basic_string interface must be documented in Clause 23 [strings].

Sub-clause 23.4.3.7.8 [string.swap] defines the swap member function with no requirements, and with guarantees to execute in constant time without throwing. Fulfilling such a contract is not reasonable in the presence of unequal non-propagating allocators.

In contrast, 24.2.2.1 [container.requirements.general] p7 declares the behavior of member swap for containers with unequal non-propagating allocators to be undefined.

Resolution proposal:

Additional language from Clause 24 [containers] should probably be copied to Clause 23 [strings]. I will refrain from an exactly recommendation, however, as I am raising further issues related to the language in Clause 24 [containers].

[2013-03-15 Issues Teleconference]

Moved to Open.

Alisdair has offered to provide wording.

Telecon notes that 24.2.2.1 [container.requirements.general]p13 says that string is an allocator-aware container.

Resolved by the adoption of P1148 in San Diego.

Proposed resolution: