CharT
in the regex librarySection: 28.6.1 [re.general] Status: New Submitter: Xie He Opened: 2022-11-28 Last modified: 2023-01-06
Priority: 4
View all issues with New status.
Discussion:
In 28.6.1 [re.general], the character type used in the regex library (CharT
),
is only required to be "char-like". This means "struct A { int m; };
" satisfies the
requirements for CharT
. Clearly there have to be more requirements for CharT
.
Comparison operators such as "==
" or "<=
" must be defined between CharT
objects, because these operators are used at various places of 28.6 [re], including
28.6.2 [re.req] paragraph 14 and 16, 28.6.6 [re.traits] paragraph 12, and
28.6.12 [re.grammar] paragraph 14. Similarly, "==
" between a CharT
object
and integer 0 must also be defined, as it is used at 28.6.2 [re.req] paragraph 11.
std::char_traits<CharT>
" comparison functions. This interpretation has the advantage
of keeping 28.6 [re] consistent with the strings library and string comparisons, which are
also used in 28.6 [re], including 28.6.2 [re.req] paragraph 7, 18, 20, and
28.6.12 [re.grammar] paragraph 14.2. Also, only with this interpretation, can
28.6.6 [re.traits] paragraph 3 be consistent with 28.6.2 [re.req] paragraph 11.There must be a way to convert between CharT
and char
, otherwise there is no
way to recognize regex syntactical characters, such as '*'
or '+'
. One way is to simply
do a type conversion from char
to CharT
(which requires char
to be convertible
to CharT
). But this doesn't allow us to convert between character encodings.
Traits
class (28.6.12 [re.grammar] paragraph 2)
denoted v
, we can use "use_facet<ctype<CharT>>(v.getloc()).widen
" to convert
from char
to CharT
. This allows us to convert between character encodings. This requires
that we can actually get this facet from this locale object.
[2023-01-06; Reflector poll]
Set priority to 4 after reflector poll.
Proposed resolution: