2151. basic_string<>::swap semantics ignore allocators

Section: 24.3.2.1 [string.require] Status: Open Submitter: Robert Shearer Opened: 2012-04-13 Last modified: 2016-11-12

Priority: 3

View all other issues in [string.require].

View all issues with Open 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 26.2 [container.requirements]; as a result, and requirements or contracts for the basic_string interface must be documented in Clause 24 [strings].

Sub-clause 24.3.2.6.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, 26.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 26 [containers] should probably be copied to Clause 24 [strings]. I will refrain from an exactly recommendation, however, as I am raising further issues related to the language in Clause 26 [containers].

[2013-03-15 Issues Teleconference]

Moved to Open.

Alisdair has offered to provide wording.

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

Proposed resolution: