<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 723: basic_regex should be moveable</title>
<meta property="og:title" content="Issue 723: basic_regex should be moveable">
<meta property="og:description" content="C++ library issue. Status: C++11">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue723.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#C++11">C++11</a> status.</em></p>
<h3 id="723"><a href="lwg-defects.html#723">723</a>. <code>basic_regex</code> should be moveable</h3>
<p><b>Section:</b> 28.6.7 <a href="https://wg21.link/re.regex">[re.regex]</a> <b>Status:</b> <a href="lwg-active.html#C++11">C++11</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2007-08-29 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#re.regex">issues</a> in [re.regex].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++11">C++11</a> status.</p>
<p><b>Discussion:</b></p>

<p><b>Addresses UK 316</b></p>

<p>
According to the current state of the standard draft, the class
template <code>basic_regex</code>, as described in 28.6.7 <a href="https://wg21.link/re.regex">[re.regex]</a>/3, is
neither <code>MoveConstructible</code> nor <code>MoveAssignable</code>.
IMO it should be, because typical regex state machines tend
to have a rather large data quantum and I have seen several
use cases, where a factory function returns regex values,
which would take advantage of moveabilities.
</p>

<p><i>[
Sophia Antipolis:
]</i></p>


<blockquote><p>
Needs wording for the semantics, the idea is agreed upon.
</p></blockquote>

<p><i>[
Post Summit Daniel updated wording to reflect new "swap rules".
]</i></p>


<p><i>[
2009-07 Frankfurt:
]</i></p>


<blockquote><p>
Move to Ready.
</p></blockquote>



<p id="res-723"><b>Proposed resolution:</b></p>
<p>
In the class definition of <code>basic_regex</code>, just below 28.6.7 <a href="https://wg21.link/re.regex">[re.regex]</a>/3,
perform the following changes:
</p>

<ol style="list-style-type:lower-alpha">
<li>
<p>
Just after <code>basic_regex(const basic_regex&amp;);</code> insert:
</p>

<blockquote><pre>
basic_regex(basic_regex&amp;&amp;);
</pre></blockquote>
</li>
<li>
<p>
Just after <code>basic_regex&amp; operator=(const basic_regex&amp;);</code> insert:
</p>
<blockquote><pre>
basic_regex&amp; operator=(basic_regex&amp;&amp;);
</pre></blockquote>
</li>
<li>
<p>
Just after <code>basic_regex&amp; assign(const basic_regex&amp; that);</code> insert:
</p>
<blockquote><pre>
basic_regex&amp; assign(basic_regex&amp;&amp; that);
</pre></blockquote>
</li>
<li>
<p>
In 28.6.7.2 <a href="https://wg21.link/re.regex.construct">[re.regex.construct]</a>, just after p.11 add the following
new member definition:
</p>
<blockquote><pre>
basic_regex(basic_regex&amp;&amp; e);
</pre>
<blockquote>
<p>
<i>Effects:</i> Move-constructs a <code>basic_regex</code> instance from <code>e</code>.
</p>
<p>
<i>Postconditions:</i> <code>flags()</code> and <code>mark_count()</code> return <code>e.flags()</code> and
<code>e.mark_count()</code>, respectively,
that <code>e</code> had before construction, leaving
<code>e</code> in a valid state with an unspecified value.
</p>
<p>
<i>Throws:</i> nothing.
</p>
</blockquote>
</blockquote>
</li>
<li>
<p>
Also in 28.6.7.2 <a href="https://wg21.link/re.regex.construct">[re.regex.construct]</a>, just after p.18 add the
following new member definition:
</p>

<blockquote><pre>
basic_regex&amp; operator=(basic_regex&amp;&amp; e);
</pre>
<blockquote><p>
<i>Effects:</i> Returns the result of <code>assign(std::move(e))</code>.
</p></blockquote>
</blockquote>
</li>
<li>
<p>
In 28.6.7.3 <a href="https://wg21.link/re.regex.assign">[re.regex.assign]</a>, just after p. 2 add the following new
member definition:
</p>
<blockquote><pre>
basic_regex&amp; assign(basic_regex&amp;&amp; rhs);
</pre>
<blockquote>
<p>
<i>Effects:</i> Move-assigns a <code>basic_regex</code> instance from <code>rhs</code> and returns <code>*this</code>.
</p>
<p>
<i>Postconditions:</i> <code>flags()</code> and <code>mark_count()</code> return <code>rhs.flags()</code>
and <code>rhs.mark_count()</code>, respectively, that
<code>rhs</code> had before assignment, leaving <code>rhs</code>
in a valid state with an unspecified value.
</p>
<p>
<i>Throws:</i> nothing.
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
