microsoft / microsoft/STL

<array>: Should array<T, N> iterators depend on N?

Open
#211 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Long ago, we made most of our iterators SCARY (see WG21-N2911 and WG21-N2980). This means that they don't depend on allocators, comparators, etc.

array<T, N> iterators are an interesting case, as they're still templated on N:

https://github.com/microsoft/STL/blob/6b0238d7035236af0f81917262691db701e70fe3/stl/inc/xutility#L2759-L2760

I believe that for IDL=0 it would be better to avoid depending on N. That would reduce instantiations and improve throughput. For IDL=2 I'm less certain - if we don't template on N, we have to store it at runtime (which probably isn't a big deal, IDL=2 is already costly). If we do template on N (like today), then we'd be setting up an unusual situation where iterator types observably change depending on IDL (not just their representations).

vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

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 with stl/inc/xutility#L2759-L2760 and the linked WG21-N2911 and WG21-N2980 papers to understand the current array<T, N> iterator design. Read #169 for the vNext constraint; done means deciding how IDL=0 and IDL=2 should depend on N and implementing the resulting ABI-breaking change once vNext is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.