This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3835. Requirements for CharT in the regex library

Section: 32.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 32.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.

  1. Comparison operators such as "==" or "<=" must be defined between CharT objects, because these operators are used at various places of 32 [re], including 32.2 [re.req] paragraph 14 and 16, 32.6 [re.traits] paragraph 12, and 32.12 [re.grammar] paragraph 14. Similarly, "==" between a CharT object and integer 0 must also be defined, as it is used at 32.2 [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 32 [re] consistent with the strings library and string comparisons, which are also used in 32 [re], including 32.2 [re.req] paragraph 7, 18, 20, and 32.12 [re.grammar] paragraph 14.2. Also, only with this interpretation, can 32.6 [re.traits] paragraph 3 be consistent with 32.2 [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 (32.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: