<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2001: Class template basic_regex uses non existent string_type</title>
<meta property="og:title" content="Issue 2001: Class template basic_regex uses non existent string_type">
<meta property="og:description" content="C++ library issue. Status: C++11">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2001.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="2001"><a href="lwg-defects.html#2001">2001</a>. Class template <code>basic_regex</code> uses non existent <code>string_type</code></h3>
<p><b>Section:</b> 28.6.7.3 <a href="https://wg21.link/re.regex.assign">[re.regex.assign]</a> <b>Status:</b> <a href="lwg-active.html#C++11">C++11</a>
 <b>Submitter:</b> Volker Lukas <b>Opened:</b> 2010-10-21 <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.assign">issues</a> in [re.regex.assign].</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>
In working draft N3126, subclause 28.6.7.3 <a href="https://wg21.link/re.regex.assign">[re.regex.assign]</a>, paragraphs 12, 13 and 19, 
the name <code>string_type</code> is used. This is presumably a typedef for <code>basic_string&lt;value_type&gt;</code>, where 
<code>value_type</code> is the character type used by <code>basic_regex</code>. The <code>basic_regex</code> 
template however defines no such typedef, and neither does the <code>&lt;regex&gt;</code> 
header or the <code>&lt;initializer_list&gt;</code> header included by <code>&lt;regex&gt;</code>.
</p>

<p><i>[
2010-11-03 Daniel comments and suggests alternative wording:
]</i></p>

<blockquote><p>
The proposed resolution needs to use <code>basic_string&lt;<strong>charT</strong>&gt;</code> instead of <code>basic_string&lt;char&gt;</code>
</p></blockquote>

<p>
Previous Proposed Resolution:
<p/>
Make the following changes to [re.regex.assign]:
</p>
<blockquote>
<pre>
basic_regex&amp; assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
</pre>
<blockquote><p>
12 <i>Returns</i>: <code>assign(<del>string_type</del><ins>basic_string&lt;charT&gt;</ins>(ptr), f)</code>. 
</p></blockquote>

<pre>
basic_regex&amp; assign(const charT* ptr, size_t len,
  flag_type f = regex_constants::ECMAScript);
</pre>
<blockquote><p>
13 <i>Returns</i>: <code>assign(<del>string_type</del><ins>basic_string&lt;charT&gt;</ins>(ptr, len), f)</code>.
</p></blockquote>

<pre>
[..]

template &lt;class InputIterator&gt; 
  basic_regex&amp; assign(InputIterator first, InputIterator last, 
                          flag_type f = regex_constants::ECMAScript);
</pre>

<blockquote><p>
18 <i>Requires</i>: The type <code>InputIterator</code> shall satisfy the requirements for an Input Iterator (24.2.3).
</p></blockquote>

<blockquote><p>
19 <i>Returns</i>: <code>assign(<del>string_type</del><ins>basic_string&lt;charT&gt;</ins>(first, last), f)</code>.
</p></blockquote>

</blockquote>

<p><i>[
2010 Batavia 
]</i></p>


<p>
Unsure if we should just give <code>basic_regex</code> a <code>string_type</code> typedef. Looking for when <code>string_type</code> was 
introduced into <code>regex</code>. Howard to draft wording for <code>typedef typename traits::string_type string_type</code>, then move to Review. 
</p>

<p><i>[
2011-02-16: Daniel comments and provides an alternative resolution.
]</i></p>


<p>
I'm strongly in favour with the Batavia idea to provide a separate <code>string_type</code> within
<code>basic_regex</code>, but it seems to me that the issue resultion should add one more
important typedef, namely that of the traits type! Currently, <code>basic_regex</code> is the
<em>only</em> template that does not publish the type of the associated traits type. Instead
of opening a new issue, I added this suggestion as part of the proposed wording.
</p>

<p><i>[2011-02-24 Reflector discussion]</i></p>

<p>
Moved to Tentatively Ready after 6 votes.
</p> 


<p id="res-2001"><b>Proposed resolution:</b></p>
<p>
Change the class template <code>basic_regex</code> synopsis, 28.6.7 <a href="https://wg21.link/re.regex">[re.regex]</a> p. 3, as indicated:</p>

<blockquote><pre>
namespace std {
  template &lt;class charT,
            class traits = regex_traits&lt;charT&gt; &gt;
  class basic_regex {
  public:
    // types:
    typedef charT value_type;
    <ins>typedef traits traits_type;</ins>
    <ins>typedef typename traits::string_type string_type;</ins>
    typedef regex_constants::syntax_option_type flag_type;
    typedef typename traits::locale_type locale_type;

    [..]
  };
}
</pre></blockquote>






</body>
</html>
