Skip to content

fix: registry::with<P> appended a policy the registry already had - #150

Merged
jll63 merged 1 commit into
boostorg:developfrom
jll63:fix/registry-with-same-policy
Nov 28, 2026
Merged

jll63 merged 1 commit into
boostorg:developfrom
jll63:fix/registry-with-same-policy

Conversation

@jll63

@jll63 jll63 commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

(Written by Claude Code, on behalf of @jll63.)

registry::with<P> is meant to replace the registry's policy in P's category, or append P if the category is empty. with_aux told the two apart by comparing the policy list before and after the replacement. When P is the very policy already in its category, the list does not change, so it was taken for "absent" and P was appended a second time:

registry<foo1>::with<foo1>                          // was registry<foo1, foo1>
default_registry::with<policies::fast_perfect_hash> // failed a static_assert:
// two or more stateful policies in this registry share the same nested `state` type

The fix asks whether the category is present directly, with mp_any_of.

Tests

Three static_asserts in test/test_policies.cpp, all of which failed before the fix: with<> of the policy already present, alone, together with a real replacement, and on default_registry.

  • gcc 13, CMake Debug with examples: 280/280; b2 (toolset=gcc): 258 passed, 0 failed.
  • MSVC 19.52, /std:c++20 /W4 /WX: test_policies.cpp compiles.

🤖 Generated with Claude Code

with_aux decided whether a policy's category was already present by
comparing the policy list before and after replacing it. When the new
policy is the one already there, the replacement leaves the list
unchanged, so it was taken for "absent" and appended a second copy:
registry<foo1>::with<foo1> was registry<foo1, foo1>, and
default_registry::with<policies::fast_perfect_hash> failed the "two or
more stateful policies ... share the same nested `state` type"
static_assert.

Ask whether the category is present with mp_any_of instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://150.openmethod.prtest3.cppalliance.org/libs/openmethod/doc/html/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-11-28 16:55:12 UTC

@codecov

codecov Bot commented Nov 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.57%. Comparing base (b681217) to head (3ed749e).
⚠️ Report is 32 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #150   +/-   ##
========================================
  Coverage    92.56%   92.57%           
========================================
  Files           29       29           
  Lines         2314     2316    +2     
  Branches       699      700    +1     
========================================
+ Hits          2142     2144    +2     
  Misses         111      111           
  Partials        61       61           
Files with missing lines Coverage Δ
include/boost/openmethod/preamble.hpp 79.31% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ff3cf6...3ed749e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jll63
jll63 merged commit cc7cb95 into boostorg:develop Nov 28, 2026
57 checks passed
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.

2 participants