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

### 2195. Missing constructors for `match_results`

Section: 30.9 [re.results] Status: Open Submitter: Daniel Krügler Opened: 2012-10-06 Last modified: 2020-09-06

Priority: 3

View all other issues in [re.results].

View all issues with Open status.

Discussion:

The requirement expressed in 30.9 [re.results] p2

> The class template `match_results` shall satisfy the requirements of an allocator-aware container and of a sequence container, as specified in 22.2.3 [sequence.reqmts], except that only operations defined for const-qualified sequence containers are supported.

can be read to require the existence of the described constructors from as well, but they do not exist in the synopsis.

The missing sequence constructors are:

>     match_results(initializer_list<value_type>);
>     match_results(size_type, const value_type&);
>     template<class InputIterator> match_results(InputIterator, InputIterator);

The missing allocator-aware container constructors are:

>     match_results(const match_results&, const Allocator&);
>     match_results(match_results&&, const Allocator&);

It should be clarified, whether (a) constructors are an exception of above mentioned operations or (b) whether at least some of them (like those accepting a `match_results` value and an allocator) should be added.

As visible in several places of the standard (including the core language), constructors seem usually to be considered as "operations" and they certainly can be invoked for const-qualified objects.

The below given proposed resolution applies only the minimum necessary fix, i.e. it excludes constructors from above requirement.

[2013-04-20, Bristol]

Check current implementations to see what they do and, possibly, write a paper.

[2013-09 Chicago]

Ask Daniel to update the proposed wording to include the allocator copy and move constructors.

[2014-01-18 Daniel changes proposed resolution]

Previous resolution from Daniel [SUPERSEDED]:

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

>    > The class template `match_results` shall satisfy the requirements of an allocator-aware container and of a sequence container, as specified in 22.2.3 [sequence.reqmts], except that only operations defined for const-qualified sequence containers that are not constructors are supported.

[2015-05-06 Lenexa]

MC passes important knowledge to EF.

VV, RP: Looks good.

TK: Second form should be conditionally noexcept

JY: Sequence constructors are not here, but mentioned in the issue writeup. Why?

TK: That would have been fixed by the superseded wording.

JW: How does this interact with Mike Spertus' allocator-aware regexes? [...] Perhaps it doesn't.

JW: Can't create match_results, want both old and new resolution.

JY: It's problematic that users can't create these, but not this issue.

VV: Why conditional noexcept?

MC: Allocator move might throw.

JW: Update superseded wording to "only non-constructor operations that are"?

MC: Only keep superseded, but append "and the means of constructing match_results are limited to [...]"?

JY: Bullet 4 paragraph 2 needs to address the allocator constructor.

Assigned to JW for drafting.

[2015-10, Kona Saturday afternoon]

STL: I want Mike Spertus to be aware of this issue.

Previous resolution from Daniel [SUPERSEDED]:

> This wording is relative to N3936.

> 1. Change 30.9 [re.results] p4, class template `match_results` synopsis, as indicated:

>    >     […]
>    >     // 28.10.1, construct/copy/destroy:
>    >     explicit match_results(const Allocator& a = Allocator());
>    >     match_results(const match_results& m);
>    >     match_results(const match_results& m, const Allocator& a);
>    >     match_results(match_results&& m) noexcept;
>    >     match_results(match_results&& m, const Allocator& a) noexcept;
>    >     […]

> 2. Change 30.9.2 [re.results.const] as indicated: [Drafting note: Paragraph 6 as currently written, makes not much sense, because the `noexcept` does not allow any exception to propagate. Further-on, the allocator requirements do not allow for throwing move constructors. Deleting it seems to be near to editorial — end drafting note]

>    >     match_results(const match_results& m);
>    >     match_results(const match_results& m, const Allocator& a);

>    > > -4- Effects: Constructs an object of class `match_results`, as a copy of `m`.

>    >     match_results(match_results&& m) noexcept;
>    >     match_results(match_results&& m, const Allocator& a) noexcept;

>    > > -5- Effects: Move-constructs an object of class `match_results` from `m` satisfying the same postconditions as Table 142. Additionally For the first form, the stored `Allocator` value is move constructed from `m.get_allocator()`.

>    > > -6- Throws: Nothing if the allocator's move constructor throws nothing.

[2019-03-27 Jonathan updates proposed resolution]

Proposed resolution:

This wording is relative to N4810.

These edits overlap with the proposed resolution of 2191 but it should be obvious how to resolve the conflicts. Both resolutions remove the word "Additionally" from p4. Issue 2191 removes the entire Throws: element in p5 but this issue replaces it with different text that applies to the new constructor only.

1. Change 30.9 [re.results] p4, class template `match_results` synopsis, as indicated:

   >     […]
   >     // 30.10.1, construct/copy/destroy:
   >     explicit match_results(const Allocator& a = Allocator());
   >     match_results(const match_results& m);
   >     match_results(const match_results& m, const Allocator& a);
   >     match_results(match_results&& m) noexcept;
   >     match_results(match_results&& m, const Allocator& a);
   >     […]

2. Change 30.9.2 [re.results.const] as indicated:

   >     match_results(const match_results& m);
   >     match_results(const match_results& m, const Allocator& a);

   > > -3- Effects: Constructs an object of class `match_results`, as a copy of `m`. For the second form, the stored `Allocator` value is constructed from `a`.

   >     match_results(match_results&& m) noexcept;
   >     match_results(match_results&& m, const Allocator& a);

   > > -4- Effects: Move-constructs an object of class `match_results` from `m` satisfying the same postconditions as Table 128. Additionally For the first form, the stored `Allocator` value is move constructed from `m.get_allocator()`. For the second form, the stored `Allocator` value is constructed from `a`.

   > > -6- Throws: Nothing. The second form throws nothing if `a == m.get_allocator()`.