Title
Requirements for CharT in the regex library
Status
new
Section
[re.general]
Submitter
Xie He

Created on 2022-11-28.00:00:00 last changed 23 months ago

Messages

Date: 2023-01-15.00:00:00

[ 2023-01-06; Reflector poll ]

Set priority to 4 after reflector poll.

Date: 2022-12-05.17:17:51

In [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.

  1. Comparison operators such as "==" or "<=" must be defined between CharT objects, because these operators are used at various places of [re], including [re.req] paragraph 14 and 16, [re.traits] paragraph 12, and [re.grammar] paragraph 14. Similarly, "==" between a CharT object and integer 0 must also be defined, as it is used at [re.req] paragraph 11.

    Alternatively, we can also interpret these operators in the text, as code implemented using "std::char_traits<CharT>" comparison functions. This interpretation has the advantage of keeping [re] consistent with the strings library and string comparisons, which are also used in [re], including [re.req] paragraph 7, 18, 20, and [re.grammar] paragraph 14.2. Also, only with this interpretation, can [re.traits] paragraph 3 be consistent with [re.req] paragraph 11.

  2. 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.

    Alternatively, if we have an object of the Traits class ([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.

History
Date User Action Args
2023-01-06 14:40:19adminsetmessages: + msg13170
2022-11-28 00:00:00admincreate