Title
basic_string's move constructor should not be noexcept
Status
nad
Section
[string.cons]
Submitter
Stephan T. Lavavej

Created on 2013-09-21.00:00:00 last changed 86 months ago

Messages

Date: 2017-03-21.22:56:50

Proposed resolution:

This wording is relative to N3691.

  1. In [basic.string]/5, class template basic_string synopsis, and [string.cons]/2 change as indicated:

    basic_string(basic_string&& str) noexcept;
    
  2. Edit [string.cons]/17 as indicated:

    basic_string(const basic_string& str, const Allocator& alloc);
    basic_string(basic_string&& str, const Allocator& alloc);
    

    […]

    -17- Throws: The second form throws nothing if alloc == str.get_allocator()..

Date: 2017-03-21.22:56:50

[ 2015-10 ]

Richard Smith pointed out that N4258 explicitly decided not to change this call; leaving it as noexcept. In response, I am changing the resolution of this issue from 'Resolved' to 'NAD'

Date: 2017-03-21.22:56:50

[ 2014/11 Urbana ]

Resolved by paper N4258

Date: 2014-03-03.13:52:20

[ 2014-02, Issaquah : move to Ready ]

The issue discussion was highly controversial: The arguments in favour was that implementations exist that always need to allocate memory even for the move operations (similar as for some other containers) and that this cleans up an inconsistency between std::string and other container types. Counter arguments were that potentially throwing move operations reduce much of the advantages of move-support, e.g. in vector<string>.

straw poll: accept wording in the issue
SF 4 WF 4 N 0 WA 1 SA 1

straw poll: 14 or 17?
C++14: 4 C++17: 4

Move to Ready for C++17, as too close to 14 DIS without strong consensus.

It was suggested to introduce a special library vocabulary that specifies a "normative encouragement to not throw exceptions" for functions like these.

NJ: I offer to write a proposal to add encouragement for not throwing ... "noexcept in italics means should not throw"

Date: 2013-09-21.00:00:00

In debugging implementations, containers (including basic_string) may need to own dynamically allocated helper objects at all times, including in their default-constructed and moved-from states. This means that their default constructors and move constructors may throw exceptions. Therefore, the Standard should not mark them as noexcept. (Other implementations will still be permitted to add noexcept.)

History
Date User Action Args
2017-03-21 22:56:50adminsetmessages: + msg9144
2017-03-21 22:56:50adminsetmessages: + msg9143
2015-10-22 08:20:57adminsetstatus: resolved -> nad
2014-11-08 18:01:47adminsetstatus: voting -> resolved
2014-11-04 10:26:50adminsetstatus: ready -> voting
2014-03-03 13:52:20adminsetstatus: new -> ready
2014-02-25 21:40:05adminsetmessages: + msg6886
2013-10-11 19:11:37adminsetmessages: + msg6706
2013-09-21 00:00:00admincreate