LWG-2220 Under-specification of `operator==` for `regex_token_iterator`

Open
#6,556 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp
Domain
backend

Research direction

Read stl/inc/regex around lines 3183–3189 and compare regex_token_iterator::operator== with the quoted WG21-N5054 Returns wording. Check the implementation against the end-of-sequence, suffix, and ordinary iterator cases; also consider whether a debug precondition check for the same underlying sequence is feasible. Done means the implementation's behavior and any proposed check are assessed against the stated requirements.

Written by the indexing model from the issue text.

Description

LWG regex

LWG-2220 Under-specification of operator== for regex_token_iterator

This LWG issue resolution is adding Preconditions, which would usually make it N/A for us, under the heading of "Something that increases the restrictions placed on users, but implementers aren't expected to enforce those restrictions." However, I'm tracking this with a GitHub issue for two reasons:

(1) We should consider whether it's feasible to add a debug precondition check for "same underlying sequence".

(2) It's unclear to me whether we correctly implement the existing Returns. Currently that's WG21-N5054 [re.tokiter.comp]/1:

bool operator==(const regex_token_iterator& right) const;
Returns: true if *this and right are both end-of-sequence iterators, or if *this and right are both suffix iterators and suffix == right.suffix; otherwise returns false if *this or right is an end-of-sequence iterator or a suffix iterator. Otherwise returns true if position == right.position, N == right.N, and subs == right.subs. Otherwise returns false.

The code doesn't immediately strike me as Doing What The Standard Says:

https://github.com/microsoft/STL/blob/0cabaf3c7e0a73fe3040aabce40cd8833e80392b/stl/inc/regex#L3183-L3189

Dominant language
C++
Stars
11.2k
Forks
1.7k
Avg merge
4d 4h
Merged PRs (30d)
14

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/STL

All issues in microsoft/STL

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.