Created on 2012-11-21.00:00:00 last changed 2 months ago
Proposed resolution:
This wording is relative to n4988.
Modify [re.tokiter.comp] as follows:
bool operator==(const regex_token_iterator& right) const;-?- Preconditions: At least one of *this and right is an end-of-sequence iterator, or *this and right have the same underlying sequence.
-1- 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`.
[ 2024-10-03; Jonathan rebases the wording on the latest WP ]
[ 2018-08-23 Casey revises the P/R in response to LWG feedback ]
This wording is relative to N4762.
Modify [re.tokiter.comp] as follows:
bool operator==(const regex_token_iterator& right) const;-?- Expects: At least one of *this and right is an end-of-sequence iterator, or both *this and right have the same underlying sequence.
-1- Returns: true if *this and right are both end-of-sequence iterators, or if […]
bool operator!=(const regex_token_iterator& right) const;-?- Expects: At least one of *this and right is an end-of-sequence iterator, or both *this and right have the same underlying sequence.
-2- Returns: !(*this == right).
[ 2018-08-20 Casey adds a proposed resolution ]
Priority changed to 3.
Marshall notes that iterator comparisons typically require the iterators to denote elements of the same sequence.Previous resolution [SUPERSEDED]:
This wording is relative to N4762.
Modify [re.tokiter.comp] as follows:
bool operator==(const regex_token_iterator& right) const;-?- Expects: *this and right are both end-of-sequence iterators or both have the same underlying sequence.
-1- Returns: true if *this and right are both end-of-sequence iterators, or if […]
bool operator!=(const regex_token_iterator& right) const;-?- Expects: *this and right are both end-of-sequence iterators or both have the same underlying sequence.
-2- Returns: !(*this == right).
[ 2014-02-10 ]
Priority set to 2
Consider the following example:
std::string str0("x"); std::regex rg0("a"); std::regex_token_iterator it0(str0.begin(), str0.end(), rg0, -1); // points at "x" in str0 std::string str1("x"); std::regex rg1("b"); std::regex_token_iterator it1(str1.begin(), str1.end(), rg1, -1); // points at "x" in str1
[re.tokiter.comp] p1 says that it0.operator==(it1) returns true "if *this and right are both suffix iterators and suffix == right.suffix"; both conditions are satisfied in this example. It does not say that they must both be iterators into the same sequence, nor does it say (as general iterator requirements do) that they must both be in the domain of == in order for the comparison to be meaningful. It's a simple statement: they're equal if the strings they point at compare equal. Given this being a valid comparison, the obtained result of "true" looks odd.
The problem is that for iterator values prior to the suffix iterator, equality means the same regular expression and the same matched sequence (both uses of "same" refer to identity, not equality); for the suffix iterator, equality means that the matched sequences compare equal.History | |||
---|---|---|---|
Date | User | Action | Args |
2024-10-03 13:06:14 | admin | set | messages: + msg14416 |
2018-08-23 14:35:23 | admin | set | messages: + msg10106 |
2018-08-22 12:55:05 | admin | set | status: new -> open |
2018-08-20 17:43:23 | admin | set | messages: + msg10087 |
2018-08-20 17:43:23 | admin | set | messages: + msg10086 |
2018-01-22 19:10:31 | admin | set | messages: + msg9618 |
2012-11-21 00:00:00 | admin | create |