Skip to content

add keyed_map - #10

Open
teoboutin wants to merge 15 commits into
masterfrom
keyed_map
Open

add keyed_map#10
teoboutin wants to merge 15 commits into
masterfrom
keyed_map

Conversation

@teoboutin

Copy link
Copy Markdown
Owner

No description provided.

A total_map that has additionally proven, at construction, that a
projection maps no two of its values to equal results -- the type-level
carrier of an emap::all_unique proof. The proven-distinct ids license
the one operation total_map cannot have: lookup by id, find(), partial
by signature (a const V*) because only unambiguity was proven, not
presence.

Construction is always through a proven table: the primary constructor
promotes a total_map (implicit and consteval, so an API taking
keyed_map demands the missing proof at the call site), and the row
authoring forms build the total_map first -- key diagnostics stay
total_map's own, verbatim, mirroring mutable_total_map's delegation.

Two new diagnostics, because the fixes differ: `duplicate value` under
the identity default (the rows are wrong) and `values collide under
projection` otherwise (question Proj before the rows). The colliding
slots ride the error functions' TEMPLATE arguments -- measured on
g++ 13.3: constant-evaluation notes echo the failing source line but do
not print evaluated runtime arguments, so the slots must be part of the
instantiated name to reach the diagnostic text. That in turn forces the
pairwise check to unroll over index_sequence rather than loop, since a
loop variable cannot be a template argument.

emap::keyable mirrors emap::buildable -- same two passing forms, same
outermost-construction portability rule -- and subsumes it: one
predicate answers for the whole construction, key checks included.

Covered by inline selftests (identity and projected ids, member-pointer
and lambda projections, string_view content equality, keyable both
forms), three negative cases pinning both new diagnostics and the
delegated key diagnostic, and the consumer test now exercising all
three headers plus a runtime find() through every install path.
teoboutin added 14 commits July 18, 2026 16:40
- join: correct the proof attribution (b's injectivity and count equality
  are not consumed by validity); bijection stays demanded, now for the
  stated re-keying guarantee.
- bijection: count-mismatch probes are hard errors, accepted with
  precedent; negative test only. Tag door needs no total_map door (from()
  is the check-free path); friendship spelled for all specializations;
  bijection<E,E> permutations are legal and get a selftest.
- Decide the pairwise-walker duplication deliberately (local twin, no
  shared detail helper).
- snapshot_map: scope the self-contained claim (id-aliasing caveat), spell
  K/V asserts and the kept copy constructor.
- Conventions: add CHANGELOG/version-bump line; fix the deferred-features
  cross-reference (§6 -> §5 Step 4+).
Also repairs two latent gaps from the keyed_map step, found by running
the full closeout here: selftest_keyed never joined the test matrix, and
the bare-copy consumer stage still staged a hand-written two-header list,
so it has been red since keyed_map.h shipped. The matrix TU list now names
every selftest TU, and the bare stage globs include/emap/*.h — a list that
reads the directory cannot go stale.
The refusal checks go through selftest-local concepts, necessarily: a
requires-expression outside a templated entity hard-errors on an invalid
expression instead of answering false. Also renames keyed_map's selftest
kFromFn to kKeyedFromFn — it collided with mutable_total_map's, and the
snapshot selftest TU is the first to compile both headers' selftests
together.
keyed_map's README section and changelog entry were owed from its own
step; batched here with the two new headers' docs, per the design doc's
author's-call clause.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant