Skip to content

docs(tutorials): migrate guards to structured-binding names - #66

Open
sentomk wants to merge 1 commit into
mainfrom
docs/structured-binding-names
Open

sentomk wants to merge 1 commit into
mainfrom
docs/structured-binding-names

Conversation

@sentomk

@sentomk sentomk commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary
Migrate the remaining tutorials from the deprecated PTN_BIND to structured-binding member names (auto [a, b] = has<...>), fix a tutorial example that never compiled, and bring the roadmap up to date with unreleased work on main.

Changes

  • other-languages, policy-constraint, sphere-constraint: declare guard names with auto [...] = has<...> instead of PTN_BIND.
  • policy-constraint: is_public_resource now takes (Role, int). A callable guard receives every member listed in has<...>, so the old one-argument version failed to compile; a short note explains this.
  • roadmap: add an unreleased block to FINISHED (has<...> tuple-like names, PTN_BIND deprecation, bare is<T>/alt<I> fast path) and fix the stale "see WIP above" reference.

Testing

  • Compiled and ran the updated snippets with g++ and clang++ in C++17 and C++20, with asserts on each rule; no warnings under -Wall -Wextra.
  • mkdocs build was not run locally.

🤖 Generated with Claude Code

Problem
- PTN_BIND is deprecated, but three tutorials still used it as the
  primary way to name guard placeholders.
- The policy tutorial's guest rule did not compile: its predicate took
  one int, but the guard passes both members listed in has<...>.
- The roadmap did not mention the unreleased has<...> naming work and
  pointed at an empty WIP section.

Implementation
- Rewrite other-languages, policy-constraint and sphere-constraint to
  declare names with auto [a, b] = has<...>.
- Make is_public_resource take (Role, int) and explain that a callable
  guard receives every member listed in has<...>.
- Add an unreleased block to the roadmap FINISHED list and fix the
  stale "see WIP above" reference.

Tests
- Compiled and ran the updated snippets with g++ and clang++ in C++17
  and C++20.

@biobo-bot biobo-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a clean docs migration. Approving the content.

What I checked

  • other-languages, policy-constraint and sphere-constraint now name guard placeholders with auto [..] = has<...> instead of the deprecated PTN_BIND, matching the tuple-like has<...> from #64 (tuple_size / tuple_element specializations with member_t<...> elements in structural.hpp).
  • The is_public_resource fix is correct: a callable guard on has<&Request::role, &Request::resource_id> receives both members, so the old (int) signature could not compile. The added sentence explaining that is helpful.
  • The note that names follow members rather than positions (reusing role from request in the guest rule) matches the member_t<&Type::name> design, and it's good to call that out explicitly.
  • Reusing the constexpr pattern object in $(u) / $(request) / $(xyz) also reduces duplication of the member list.
  • Roadmap: the unreleased block lines up with #63 and #64 on main, and replacing the stale "see WIP above" with "shipped in v0.9.4" is right.

CI items to sort out before merge (not about the doc content)

  1. commit-style fails because the PR body is missing the required sections. It expects **Summary**, **Changes** and **Testing** headings; the current body uses Problem / Implementation / Tests. Renaming those sections in the PR description should fix it (no new commit needed).
  2. clang-14 C++17 and clang-16 C++20 fail at the setup step with E: Package 'clang-14' has no installation candidate (apt exit 100). That looks like the ubuntu-latest runner image moving to a newer Ubuntu, not this PR. Pinning those jobs to ubuntu-22.04/ubuntu-24.04 or installing from apt.llvm.org in a separate PR should unblock it.

Nit (optional): in sphere-constraint, x and y are unused. GCC/Clang don't warn as long as one binding is used, so this is fine, but if you want to model it for users you could mention [[maybe_unused]] auto [x, y, z] = xyz; for cases where none are used.

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark comparison (informational)

Base 73afb3d vs PR 4478401, run one after the other on the same GitHub-hosted runner. This does not block merging.

Noise estimate: the 20 control rows below do not run Patternia code, so they should not change between base and PR. As a group they moved by a median of +0.0% (run order and machine drift); that offset is divided out of the Patternia deltas (Adjusted). The controls then scatter by a median of 0.3%. Adjusted differences under 5.0% are treated as noise.

Patternia: 8 benchmarks, 1 slower, 0 faster, 7 within noise.

Benchmark Base (ns) PR (ns) Delta Adjusted Verdict
PatterniaPipe CommandParser 1.634 1.635 +0.1% +0.1% within noise
PatterniaPipe PacketMixed 1.410 1.408 -0.2% -0.2% within noise
PatterniaPipe PacketMixedHeavyBind 1.521 1.508 -0.8% -0.8% within noise
PatterniaPipe ProtocolRouter 1.318 1.346 +2.1% +2.1% within noise
PatterniaPipe VariantAltHot 1.256 1.363 +8.5% +8.5% slower
PatterniaPipe VariantAltHotGuarded 1.500 1.500 +0.0% +0.0% within noise
PatterniaPipe VariantMixed 1.653 1.653 -0.0% -0.0% within noise
PatterniaPipe VariantMixedGuarded 1.521 1.522 +0.1% +0.1% within noise
Control rows (not Patternia code)
Benchmark Base (ns) PR (ns) Delta
IfElse CommandParser 1.444 1.439 -0.3%
IfElse ProtocolRouter 1.725 1.686 -2.3%
Sequential VariantAltHot 2.318 2.320 +0.0%
Sequential VariantAltHotGuarded 2.319 2.319 +0.0%
Sequential VariantMixed 0.906 0.904 -0.1%
Sequential VariantMixedGuarded 0.942 0.946 +0.4%
StdVisit CommandParser 1.107 1.111 +0.4%
StdVisit ProtocolRouter 1.316 1.306 -0.7%
StdVisit VariantAltHot 1.773 2.183 +23.1%
StdVisit VariantAltHotGuarded 2.318 2.318 +0.0%
StdVisit VariantMixed 1.725 2.471 +43.2%
StdVisit VariantMixedGuarded 1.792 1.791 -0.0%
SwitchIndex VariantAltHot 2.321 2.320 -0.0%
SwitchIndex VariantAltHotGuarded 2.456 2.456 +0.0%
SwitchIndex VariantMixed 0.828 0.828 +0.0%
SwitchIndex VariantMixedGuarded 0.898 0.898 -0.0%
Switch CommandParser 1.392 1.396 +0.3%
Switch PacketMixed 1.228 1.217 -0.9%
Switch PacketMixedHeavyBind 1.244 1.250 +0.5%
Switch ProtocolRouter 1.358 1.381 +1.7%

Raw results and the comparison chart are attached to this workflow run as an artifact. Shared runners are noisy, so use this as a trend, not a measurement.

This branch has not been deployed

No deployments
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