Skip to content

registry affinity: correct the reference, and stop expanding va_args thrice - #111

Merged
jll63 merged 1 commit into
boostorg:developfrom
jll63:fix/registry-affinity-docs
Sep 15, 2026
Merged

jll63 merged 1 commit into
boostorg:developfrom
jll63:fix/registry-affinity-docs

Conversation

@jll63

@jll63 jll63 commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

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

Follow-ups from the review of #96, all mechanical. No behaviour changes.

The reference described the pre-affinity default in five places

BOOST_OPENMETHOD_DEFAULT_REGISTRY's own page said it was "the default value
for the Registry template parameter of method, use_classes,
virtual_ptr, and all the constructs that take a registry as a template
argument" - after #96 only use_classes is still true. The virtual_ptr class,
the one-argument final_virtual_ptr, and the @note on each of
BOOST_OPENMETHOD and BOOST_OPENMETHOD_CLASSES said variants of the same
thing. Each now says what the construct actually defaults to, and the
BOOST_OPENMETHOD_CLASSES note says plainly that it does not consult
affinities - which is the trap registries_and_policies.adoc already warns
about, and which a reader of the reference page had no way to learn. The page's
own opening paragraph gets the same correction, and class method's
description still carried a paragraph contradicting its @tparam Registry.

class method had no description in the reference at all

MrDocs does not attach a //! comment to a declaration when a namespace
definition comes between them, and the namespace detail { ... } holding the
affinity scan had been inserted exactly there - so the rendered page kept the
three @tparam lines and lost the call semantics and the four
overrider-selection steps. The block moves above the comment, which now touches
the declaration it documents.

BOOST_OPENMETHOD_TYPE expanded va_args three times

It computed a registry and handed it back to method, spelling
va_args<__VA_ARGS__> three times and the parameter list twice - 30-36% more
preprocessor output per declaration, measured with g++ -E -P. A method_type
alias template on the two va_args specializations names the method directly,
so the macro spells va_args twice and the parameter list once. It stays an
alias template, so the specialization that omits the registry still leaves
method's own default to scan the parameters, and the one that names a registry
still never triggers that scan. va_args::registry had no consumer left in the
tree and goes.

Two smaller ones

Three explanatory comments inside the tagged regions of adl_registry.cpp move
to the page that includes them, per the rule in CLAUDE.md - they were
rendering into the snippets.

Two tests stop naming BOOST_OPENMETHOD_DEFAULT_REGISTRY in a comment.
test/CMakeLists.txt scans sources for that token to decide which tests must
not receive the force-included PCH; a mention in prose was enough to withhold
it, which is what #96's own note in CLAUDE.md said should not happen for
affinity tests.

Tests

185/185 under gcc 13.3 Release with examples, 191/191 under gcc 16 with C++26
reflection and BUILD_SHARED_LIBS=ON, both with
BOOST_OPENMETHOD_WARNINGS_AS_ERRORS=ON.

Still open from the review

Not in this PR, because each needs a decision rather than a correction: a
derived class overriding its base's affinity makes virtual_ptr<Derived>
non-convertible to virtual_ptr<Base> and short-form overriders fail with a
misleading "cannot find method"; use_classes and the C++26 reflection
registrar still default to the macro instead of following affinities;
virtual_ptr_alt.adoc does not mention that initialize() does not follow an
affinity either, and two of adl_registry.cpp's tags are included by no page;
the recommended hidden friend trips gcc's -Wnon-template-friend on a
class-template root, undocumented; and the doc example is the only one written
as a Boost.Test module, duplicating test_adl_registry.cpp.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RQG6CbE4o2agseE7bDVzHS

…thrice

Follow-ups from the review of boostorg#96, all mechanical.

The reference still described the pre-affinity default in five places: the
`BOOST_OPENMETHOD_DEFAULT_REGISTRY` page ("the default value for the Registry
template parameter of method, use_classes, virtual_ptr, and all the constructs
that take a registry" - only `use_classes` is still true), the `virtual_ptr`
class, the one-argument `final_virtual_ptr`, and the `@note` on each of
`BOOST_OPENMETHOD` and `BOOST_OPENMETHOD_CLASSES`. Each now says what the
construct actually defaults to, and the `BOOST_OPENMETHOD_CLASSES` note says
plainly that it does *not* consult affinities - the trap the page warns about.
`registries_and_policies.adoc` gets the same correction in its opening
paragraph, and `class method`'s own description still carried a paragraph
contradicting its `@tparam Registry`.

That description was also missing from the reference entirely: MrDocs does not
attach a `//!` comment to a declaration when a namespace definition comes
between them, and the `namespace detail { ... }` holding the affinity scan had
been inserted there. The block moves above the comment, which now touches
`class method` as it must. Rendered `method` page keeps its call semantics and
overrider-selection steps.

`BOOST_OPENMETHOD_TYPE` expanded `va_args<__VA_ARGS__>` three times and the
parameter list twice, to compute a registry and hand it back to `method`:
30-36% more preprocessor output per declaration, measured with `g++ -E -P`. A
`method_type` alias on the two `va_args` specializations names the method
directly, so the macro spells `va_args` twice and the parameter list once, and
the affinity scan still never runs for a declaration that names a registry.
`va_args::registry` had no consumer left in the tree and goes.

Also: three explanatory comments inside the tagged regions of
`adl_registry.cpp` moved to the page that includes them, per the rule in
CLAUDE.md, and two tests stop naming `BOOST_OPENMETHOD_DEFAULT_REGISTRY` in a
comment - `test/CMakeLists.txt` scans for that token to decide which tests must
not get the shared PCH, and a mention in prose was enough to withhold it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQG6CbE4o2agseE7bDVzHS
@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://111.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-09-15 12:57:03 UTC

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.25%. Comparing base (d44aa59) to head (e7f1970).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #111      +/-   ##
===========================================
- Coverage    93.51%   93.25%   -0.26%     
===========================================
  Files           22       22              
  Lines         1695     1706      +11     
  Branches       504      509       +5     
===========================================
+ Hits          1585     1591       +6     
- Misses          66       71       +5     
  Partials        44       44              
Files with missing lines Coverage Δ
include/boost/openmethod/core.hpp 91.60% <ø> (-1.49%) ⬇️

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 28494b6...e7f1970. 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 8db9d0c into boostorg:develop Sep 15, 2026
53 of 56 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