microsoft / microsoft/STL

<algorithm>: investigate sharing code between std and ranges algorithms

Open
#1,754 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

There's an enormous amount of overlap in implementations of the "same" algorithm in namespaces std and std::ranges. For example, std::copy:

https://github.com/microsoft/STL/blob/2d890fdadde44bdb8eced76f29803ce2ecbe0378/stl/inc/xutility#L4119-L4146

vs. ranges::copy:

https://github.com/microsoft/STL/blob/2d890fdadde44bdb8eced76f29803ce2ecbe0378/stl/inc/algorithm#L1507-L1547

There are substantial differences in the interface, but eventually they boil down to identical or nearly identical loops. It would be nice if we could reduce the total amount of code we must maintain by using a common back-end for such algorithms.

Note that in doing so we absolutely must not regress performance or codesize, and should not regress compile throughput or increase the complexity of the overall code.

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

Compare the std::copy implementation in stl/inc/xutility and the ranges::copy implementation in stl/inc/algorithm. First determine which shared backend opportunities preserve both interfaces, then measure performance, code size, compile throughput, and overall complexity to establish whether the work is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
developer-experience
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.