3800. No deduction guide for std::match_results

Section: 28.6.9.1 [re.results.general] Status: NAD Submitter: Jonathan Wakely Opened: 2022-10-25 Last modified: 2022-11-30

Priority: Not Prioritized

View all issues with NAD status.

Discussion:

std::match_results meets some of the requirements for an allocator-aware container, which means that its allocator_type must have the same value_type as the container. This means that class template argument deduction should work for:

std::match_results mr(alloc);

The allocator's value_type will be the sub_match<Iter> type stored in the match_results object, and so the first template argument for the match_results type will be value_type::iterator.

P0433R2 added a deduction guide for std::basic_regex, but I see no rationale for not adding one for std::match_results. This seems like a defect, because all other allocator-aware containers support deduction from an allocator argument.

[2022-11-01; reflector poll]

Status changed to Tentatively NAD. The issue is wrong: other containers do not support deduction from an allocator type.

[2022-11-30 LWG telecon. Status changed: Tentatively NAD → NAD.]

Proposed resolution:

This wording is relative to N4917.

  1. Modify 28.6.9.1 [re.results.general], class template match_results synopsis, as indicated:

    namespace std {
      template<class BidirectionalIterator,
               class Allocator = allocator<sub_match<BidirectionalIterator>>>
        class match_results {
          […]
          void swap(match_results& that);
        };
        
      template<class Allocator>
        match_results(Allocator) -> match_results<typename Allocator::value_type::iterator, Allocator>;
    }