docs(containers): fix the constexpr FlatMap example & find wording (roadmap 11.7) - #46
Merged
Merged
Conversation
…oadmap 11.7) Close the last Milestone-11 item — the discrepancy that started the milestone. Reconcile spec §5: it claimed "FlatMap::find returns an optional-like result", but the shipped API returns a const_iterator compared to end() (the STL-idiomatic form). Reword §5 to state the actual per-channel error model (iterator for associative lookup, std::optional for a missing element, status types for N-way outcomes), pointing at ADR-0029 and the contract table. Make the illustrative "constexpr FlatMap" example real: the intake's example used find(1).has_value(), which never compiled against the iterator API. Add the corrected example as a compile-verified static_assert in flat_map_test.cpp (constexpr construction + iterator find over FlatMap<int, std::string_view>) and as a Doxygen snippet in flat_map.hpp — so the example both compiles and matches its "constexpr" title. Marks Milestone 11 (Specification & Assurance Hardening) complete in README + ROADMAP. Doc/test only; no library logic change. Local verify (MSVC): util_tests green incl. the new constexpr static_assert; clang-format + clang-tidy clean; consistency_lint passing. Refs roadmap 11.7 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the original discrepancy that started Milestone 11: reconciles the spec §5
findwordingwith the shipped iterator API, and turns the illustrative "constexpr FlatMap" example into a
compile-verified one. Closes Milestone 11. Doc/test only; no library logic change.
Motivation
Spec-review acceptance criterion: "the §3 example compiles and matches its title," and the §5
error-model reconciliation. Roadmap item 11.7.
Changes
FlatMap::findreturns an optional-like result"; the shippedAPI returns a
const_iteratorcompared toend(). §5 now states the actual per-channel errormodel (iterator for associative lookup;
std::optionalfor a missing element; status types forN-way outcomes), pointing at ADR-0029 and
the contract table.
find(1).has_value(), which never compiled against the iterator API. The corrected example isadded (a) as a compile-verified
static_assertinflat_map_test.cpp(
FlatMap<int, std::string_view>, insert, iterator-basedfind, in a constant expression) and(b) as a Doxygen snippet in
flat_map.hpp. It now compiles and matches its "constexpr" title.Design Patterns
Verification
util_testsgreen including the new constexprstatic_assert(afailure would fail the build); FlatMap cases pass.
clang-formatandclang-tidyclean on the changed sources.python tools/consistency_lint.pypasses (M11 all-checked; README ↔ ROADMAP consistent).Documentation Impact
docs