Title
match_results can't satisfy the requirements of a container
Status
c++17
Section
[re.results]
Submitter
S. B. Tam

Created on 2016-01-24.00:00:00 last changed 90 months ago

Messages

Date: 2016-11-13.13:00:42

Proposed resolution:

This wording is relative to N4567.

  1. Change [re.results] p2 as indicated:

    -2- The class template match_results shall satisfysatisfies the requirements of an allocator-aware container and of a sequence container, as specified in (23.2.3), except that only operations defined for const-qualified sequence containers are supported and the semantics of comparison functions are different from those required for a container.

[Drafting note: (Post-Issaquah) Due to the outdated N4567 wording the project editor accepted the following merge suggestion into N4606 wording: — end drafting note]

This wording is relative to N4606.

  1. Change [re.results] p2 as indicated:

    -2- The class template match_results satisfies the requirements of an allocator-aware container and of a sequence container, as specified in ([container.requirements.general] and, [sequence.reqmts]) respectively, except that only operations defined for const-qualified sequence containers are supported and the semantics of comparison functions are different from those required for a container.

Date: 2016-11-13.13:00:42

[ 2016-08 - Chicago ]

Thurs AM: Moved to Tentatively Ready

Previous resolution [SUPERSEDED]:

This wording is relative to N4567.

  1. Change [re.results] p2 as indicated:

    -2- The class template match_results shall satisfy the requirements of an allocator-aware container and of a sequence container, as specified in 23.2.3, except that only operations defined for const-qualified sequence containers are supported and that the semantics of comparison functions are different from those required for a container.

Date: 2016-05-19.17:42:45
Marshall: The submitter is absolutely right, but the proposed resolution is insufficient. We should avoid "shall", for once.

[ 2016-02, Issues Telecon ]

Marshall: The submitter is absolutely right, but the proposed resolution is insufficient. We should avoid "shall", for once.
Jonathan: This is NAD, because the container comparison functions say "unless otherwise stated", 23.3.1p14 and table 97.
Ville: wrong, table 95 is relevant for ==.
Jonathan: good point

2016-05: Marshall cleans up the wording around the change

Date: 2016-01-24.00:00:00

N4567 [re.results] p2 mentions

The class template match_results shall satisfy the requirements of an allocator-aware container and of a sequence container, as specifed in 23.2.3, except that only operations defined for const-qualified sequence containers are supported.

However, this is impossible because match_results has a operator== whose semantics differs from the one required in Table 95 — "Container requirements".

Table 95 requires that a == b is an equivalence relation and means equal(a.begin(), a.end(), b.begin(), b.end()). But for match_results, a == b and equal(a.begin(), a.end(), b.begin(), b.end()) can give different results. For example:

#include <iostream>
#include <regex>
#include <string>
#include <algorithm>

int main()
{
  std::regex re("a*");
  std::string target("baaab");
  std::smatch a;

  std::regex_search(target, a, re);

  std::string target2("raaau");
  std::smatch b;

  std::regex_search(target2, b, re);

  std::cout << std::boolalpha;
  std::cout << (a == b) << '\n'; // false
  std::cout << std::equal(a.begin(), a.end(), b.begin(), b.end()) << '\n'; // true
}
History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-08-05 03:33:05adminsetmessages: + msg8415
2016-08-05 03:33:05adminsetstatus: new -> ready
2016-02-07 20:24:45adminsetmessages: + msg7976
2016-01-30 14:21:39adminsetmessages: + msg7945
2016-01-24 00:00:00admincreate