microsoft / microsoft/STL

<regex>: Should regex_match() use the match_results allocator?

Open
#174 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement LWG issue needed regex
Dominant language
C++
Stars
11.2k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

Reported by https://stackoverflow.com/questions/58399158/use-custom-allocator-for-stdregex-match .

Calling regex_match() or regex_search() with a match_results containing a custom allocator ends up constructing ordinary vector containers in _Matcher, specifically:

https://github.com/microsoft/STL/blob/6aa3b02fde6f885581279ff28d7a6b4f3e38fcb7/stl/inc/regex#L1650-L1652

The Standard is silent on this topic, but libc++ uses the match_results allocator here.

It may be possible to fix this while preserving ABI, by renaming _Matcher (which is a large but internal helper class).

Note: <regex> mostly ignores the existence of allocators; see LWG-1396 "regex should support allocators" and LWG-2216 "regex_replace(basic_string) allocator handling" for examples.

Contributor guide

Open the contributing guide

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.

Research direction

Start in stl/inc/regex at the _Matcher construction around lines 1650-1652, then review how regex_match() and regex_search() use match_results with custom allocators. Compare the libc++ behavior and the referenced LWG-1396 and LWG-2216 discussions. Done means the allocator behavior is resolved while preserving ABI, with the affected custom-allocator cases validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.