<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3341: basic_regex range constructor: Missing requirements for iterator types</title>
<meta property="og:title" content="Issue 3341: basic_regex range constructor: Missing requirements for iterator types">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3341.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#New">New</a> status.</em></p>
<h3 id="3341"><a href="lwg-active.html#3341">3341</a>. <code>basic_regex</code> range constructor: Missing requirements for iterator types</h3>
<p><b>Section:</b> 28.6.7.2 <a href="https://wg21.link/re.regex.construct">[re.regex.construct]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> &Dcy;&iecy;&ncy;&icy;&scy; &Zcy;&acy;&khcy;&acy;&rcy;&ocy;&vcy; <b>Opened:</b> 2019-11-17 <b>Last modified:</b> 2022-04-22</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#re.regex.construct">active issues</a> in [re.regex.construct].</p>
<p><b>View all other</b> <a href="lwg-index.html#re.regex.construct">issues</a> in [re.regex.construct].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
This is description of a <code>basic_regex</code> range constructor from <a href="https://wg21.link/n4835">N4835</a>,
28.6.7.2 <a href="https://wg21.link/re.regex.construct">[re.regex.construct]</a>:
</p>
<blockquote>
<pre>
template&lt;class ForwardIterator&gt;
  basic_regex(ForwardIterator first, ForwardIterator last,
              flag_type f = regex_constants::ECMAScript);
</pre>
<blockquote>
<p>
-17- <i>Throws:</i> <code>regex_error</code> if the sequence <code>[first, last)</code> is not a valid regular expression.
<p/>
-18- <i>Effects:</i> Constructs an object of class <code>basic_regex</code>; the object's internal finite state 
machine is constructed from the regular expression contained in the sequence of characters <code>[first, last)</code>, 
and interpreted according to the flags specified in <code>f</code>.
<p/>
-19- <i>Ensures:</i> <code>flags()</code> returns <code>f. mark_count()</code> returns the number of marked sub-expressions 
within the expression.
</p>
</blockquote>
</blockquote>
<p>
It seems that there are no requirements about dereferenced iterator's element type, that, apparently, 
must be implicitly convertible to the <code>basic_regex::value_type</code>. For example, containers having 
range constructor satisfy a SequenceContainer requirements, where implicit converting to its elements 
is specified.
</p>

<p><i>[2019-11-30 Issue Prioritization]</i></p>

<p>Priority to 3 after reflector discussion.</p>

<p><i>[2021-10-04; Jonathan adds a comment]</i></p>

<p>
There isn't even a requirement that the arguments are iterators.
And <code>assign(InputIterator, InputIterator, flag_type)</code> is not
constrained to only accept iterators either, meaning you can call it with
two integers and call the
<code>basic_string(size_type, char_type)</code> constructor.
</p>

<p><i>[2022-04-22; Jonathan adds a comment]</i></p>

<p>
As well as requiring the reference type to be convertible to <code>charT</code>,
we might want to consider constraining these with <code>forward_iterator</code>
as per <a href="https://wg21.link/p2408">P2408</a>.
</p>


<p id="res-3341"><b>Proposed resolution:</b></p>




</body>
</html>
