refactor: replace per-type operator==() and operator<=>() with a single generic template for doc types#1177
Conversation
|
| Scope | Lines Δ% | Lines Δ | Lines + | Lines - | Files Δ | Files + | Files ~ | Files ↔ | Files - |
|---|---|---|---|---|---|---|---|---|---|
| 🛠️ Source | 100% | 450 | 100 | 350 | 45 | 1 | 44 | - | - |
| Total | 100% | 450 | 100 | 350 | 45 | 1 | 44 | - | - |
Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)
🔝 Top Files
- include/mrdocs/Support/CompareReflectedType.hpp (Source): 87 lines Δ (+87 / -0)
- include/mrdocs/Metadata/DocComment/Inline/InlineBase.hpp (Source): 32 lines Δ (+6 / -26)
- include/mrdocs/Metadata/DocComment/Block/BlockBase.hpp (Source): 29 lines Δ (+6 / -23)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1177 +/- ##
===========================================
+ Coverage 78.46% 78.64% +0.17%
===========================================
Files 336 311 -25
Lines 32219 32161 -58
Branches 6480 6473 -7
===========================================
+ Hits 25282 25292 +10
+ Misses 4567 4498 -69
- Partials 2370 2371 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
An automated preview of the documentation is available at https://1177.mrdocs.prtest2.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-04-10 14:34:06 UTC |
…le generic template for doc types Add a reflection-based operator<=>() and operator==() template pair that compare bases then members using the MRDOCS_DESCRIBE metadata. This removes ~40 per-type = default and hand-written operator<=>() implementations from all DocComment Block and Inline types. The templates live in mrdocs::describe_ops rather than mrdocs to work around an MSVC bug: adding any constrained template to namespace mrdocs causes the unrelated merge() template to fail resolving recursive calls from within lambdas, even though both templates are well-formed C++ (confirmed with clang-cl 21.1.5). As a consequence, the operator<=>() overloads in namespace mrdocs (Symbol, Type, Name, Template types, etc.) cannot be replaced yet — the generic template is not reachable by ADL from that namespace, and importing it via using-declarations triggers the bug.
6ad7c2d to
2f73a34
Compare
alandefreitas
left a comment
There was a problem hiding this comment.
Looks amazing to me!
|
Thanks. Unfortunately, that MSVC bug doesn't allow removing more overloads. |
I'm a little confused by the limitation. So the operator<=>() overloads in namespace mrdocs can't be replaced, but the ones in mrdocs::doc can? Or both can't? And if both can't, what can? I think from the description alone I couldn't mentally visualize all the instances of the problem described. |
|
The overloads in `mrdocs` can't. The ones in `mrdocs::doc` can.
|
Oh... I really don't understand this bug then. :) I'll study it a little better. |
Add a reflection-based operator<=>() and operator==() template pair that compare bases then members using the MRDOCS_DESCRIBE metadata. This removes ~40 per-type = default and hand-written operator<=>() implementations from all DocComment Block and Inline types.
The templates live in mrdocs::describe_ops rather than mrdocs to work around an MSVC bug: adding any constrained template to namespace mrdocs causes the unrelated merge() template to fail resolving recursive calls from within lambdas, even though both templates are well-formed C++ (confirmed with clang-cl 21.1.5). As a consequence, the operator<=>() overloads in namespace mrdocs (Symbol, Type, Name, Template types, etc.) cannot be replaced yet — the generic template is not reachable by ADL from that namespace, and importing it via using-declarations triggers the bug.