<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3835: Requirements for CharT in the regex library</title>
<meta property="og:title" content="Issue 3835: Requirements for CharT in the regex library">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3835.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="3835"><a href="lwg-active.html#3835">3835</a>. Requirements for <code>CharT</code> in the regex library</h3>
<p><b>Section:</b> 28.6.1 <a href="https://wg21.link/re.general">[re.general]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Xie He <b>Opened:</b> 2022-11-28 <b>Last modified:</b> 2023-01-06</p>
<p><b>Priority: </b>4
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
In 28.6.1 <a href="https://wg21.link/re.general">[re.general]</a>, the character type used in the regex library (<code>CharT</code>), 
is only required to be "char-like". This means "<code>struct A { int m; };</code>" satisfies the 
requirements for <code>CharT</code>. Clearly there have to be more requirements for <code>CharT</code>.
</p>
<ol>
<li><p>Comparison operators such as "<code>==</code>" or "<code>&lt;=</code>" must be defined between <code>CharT</code> 
objects, because these operators are used at various places of 28.6 <a href="https://wg21.link/re">[re]</a>, including 
28.6.2 <a href="https://wg21.link/re.req">[re.req]</a> paragraph 14 and 16, 28.6.6 <a href="https://wg21.link/re.traits">[re.traits]</a> paragraph 12, and 
28.6.12 <a href="https://wg21.link/re.grammar">[re.grammar]</a> paragraph 14. Similarly, "<code>==</code>" between a <code>CharT</code> object 
and integer 0 must also be defined, as it is used at 28.6.2 <a href="https://wg21.link/re.req">[re.req]</a> paragraph 11.

<p/>
Alternatively, we can also interpret these operators in the text, as code implemented using 
"<code>std::char_traits&lt;CharT&gt;</code>" comparison functions. This interpretation has the advantage 
of keeping 28.6 <a href="https://wg21.link/re">[re]</a> consistent with the strings library and string comparisons, which are 
also used in 28.6 <a href="https://wg21.link/re">[re]</a>, including 28.6.2 <a href="https://wg21.link/re.req">[re.req]</a> paragraph 7, 18, 20, and 
28.6.12 <a href="https://wg21.link/re.grammar">[re.grammar]</a> paragraph 14.2. Also, only with this interpretation, can
28.6.6 <a href="https://wg21.link/re.traits">[re.traits]</a> paragraph 3 be consistent with 28.6.2 <a href="https://wg21.link/re.req">[re.req]</a> paragraph 11.</p></li>
<li><p>There must be a way to convert between <code>CharT</code> and <code>char</code>, otherwise there is no 
way to recognize regex syntactical characters, such as <code>'*'</code> or <code>'+'</code>. One way is to simply 
do a type conversion from <code>char</code> to <code>CharT</code> (which requires <code>char</code> to be convertible 
to <code>CharT</code>). But this doesn't allow us to convert between character encodings.
<p/>
Alternatively, if we have an object of the <code>Traits</code> class (28.6.12 <a href="https://wg21.link/re.grammar">[re.grammar]</a> paragraph 2) 
denoted <code>v</code>, we can use "<code>use_facet&lt;ctype&lt;CharT&gt;&gt;(v.getloc()).widen</code>" to convert 
from <code>char</code> to <code>CharT</code>. This allows us to convert between character encodings. This requires 
that we can actually get this facet from this locale object.
</p></li>
</ol>

<p><i>[2023-01-06; Reflector poll]</i></p>

<p>
Set priority to 4 after reflector poll.
</p>



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





</body>
</html>
