<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2319: basic_string's move constructor should not be noexcept</title>
<meta property="og:title" content="Issue 2319: basic_string's move constructor should not be noexcept">
<meta property="og:description" content="C++ library issue. Status: NAD">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2319.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#NAD">NAD</a> status.</em></p>
<h3 id="2319"><a href="lwg-closed.html#2319">2319</a>. <code>basic_string</code>'s move constructor should not be <code>noexcept</code></h3>
<p><b>Section:</b> 27.4.3.3 <a href="https://wg21.link/string.cons">[string.cons]</a> <b>Status:</b> <a href="lwg-active.html#NAD">NAD</a>
 <b>Submitter:</b> Stephan T. Lavavej <b>Opened:</b> 2013-09-21 <b>Last modified:</b> 2017-03-21</p>
<p><b>Priority: </b>1
</p>
<p><b>View all other</b> <a href="lwg-index.html#string.cons">issues</a> in [string.cons].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
<p><b>Discussion:</b></p>
<p>
In debugging implementations, containers (including <code>basic_string</code>) 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 <code>noexcept</code>. (Other implementations will 
still be permitted to add <code>noexcept</code>.)
</p>

<p><i>[2014-02, Issaquah : move to Ready]</i></p>

<p>
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 <code>std::string</code>
and other container types. Counter arguments were that potentially throwing move operations reduce much of the advantages of move-support,
e.g. in <code>vector&lt;string&gt;</code>.
</p>
<p>
straw poll: accept wording in the issue<br/>
SF 4 WF 4 N 0 WA 1 SA 1 
</p>
<p>
straw poll: 14 or 17?<br/>
C++14: 4 C++17: 4 
</p>
<p>
Move to Ready for C++17, as too close to 14 DIS without strong consensus.
</p>
<p>
It was suggested to introduce a special library vocabulary that specifies a "normative encouragement to not throw exceptions" for 
functions like these. 
</p>
<p>
NJ: I offer to write a proposal to add encouragement for not throwing ... "<code>noexcept</code> in italics means should not throw" 
</p>

<p><i>[2014/11 Urbana]</i></p>

<p>
Resolved by paper <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4258">N4258</a>
</p>

<p><i>[2015-10]</i></p>

<p>
Richard Smith pointed out that <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4258">N4258</a>
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'
</p>

<p id="res-2319"><b>Proposed resolution:</b></p>
<p>This wording is relative to N3691.</p>

<ol>
<li><p>In 27.4.3 <a href="https://wg21.link/basic.string">[basic.string]</a>/5, class template <code>basic_string</code> synopsis, and 27.4.3.3 <a href="https://wg21.link/string.cons">[string.cons]</a>/2 
change as indicated:</p>

<blockquote><pre>
basic_string(basic_string&amp;&amp; str) <del>noexcept</del>;
</pre></blockquote>
</li>

<li><p>Edit 27.4.3.3 <a href="https://wg21.link/string.cons">[string.cons]</a>/17 as indicated:</p>

<blockquote><pre>
basic_string(const basic_string&amp; str, const Allocator&amp; alloc);
basic_string(basic_string&amp;&amp; str, const Allocator&amp; alloc);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
<del>-17- <i>Throws:</i> The second form throws nothing if <code>alloc == str.get_allocator()</code>.</del>.
</p>
</blockquote>
</blockquote>
</li>

</ol>






</body>
</html>
