Skip to content

Extend operator support - #282

Draft
jbcoe wants to merge 6 commits into
mainfrom
jbcoe-more-operators-252
Draft

Extend operator support#282
jbcoe wants to merge 6 commits into
mainfrom
jbcoe-more-operators-252

Conversation

@jbcoe

@jbcoe jbcoe commented Sep 1, 2026

Copy link
Copy Markdown
Owner

No description provided.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.95%. Comparing base (987b1bd) to head (65c567e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
protocol.hh 88.88% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #282      +/-   ##
==========================================
+ Coverage   72.87%   72.95%   +0.08%     
==========================================
  Files           9        9              
  Lines         822      832      +10     
  Branches      208      208              
==========================================
+ Hits          599      607       +8     
- Misses         24       25       +1     
- Partials      199      200       +1     
Flag Coverage Δ
consteval 96.55% <92.85%> (-0.92%) ⬇️
runtime 70.20% <75.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Comment thread name_mangling.h
// <source-name> for its identifier otherwise. `identifier_of` throws for
// `operator()`, which has no identifier.
// <operator-name> for a supported operator function, or a length-prefixed
// <source-name> for its identifier otherwise. `identifier_of` throws for an

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Rephrase "identifier_of` throws for an operator function, which has no identifier."

Comment thread protocol.hh
consteval bool same_name(std::meta::info a, std::meta::info b) {
if (is_call_operator(a) || is_call_operator(b))
return is_call_operator(a) && is_call_operator(b);
bool a_is_operator = is_operator_function(a);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This feels convoluted.

Comment thread protocol.hh
// viewed/owned object.
R operator()(Args... args) noexcept(IsNoexcept)
protected:
// Widens the EnclosingType pointer to the enclosing protocol/protocol_view

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

"Widens" here is odd

Comment thread operators.h
#ifndef XYZ_REFLECTION_OPERATORS_H_
#define XYZ_REFLECTION_OPERATORS_H_

// The overloadable operators a protocol interface may declare as member

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Condense this comment block.

Comment thread protocol_test.cc
EXPECT_EQ(p[21], 42);
}

// Other operator tests for protocol. These exercise the operator table: a

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This comment block is unneccesary.

Comment thread protocol.hh
// function's signature (see "name_mangling.h"), so an entry can be found by
// the signature it implements rather than by declaration order.
//
// Neither implementation currently supports operators other than operator().

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This comment is not needed.

Comment thread protocol.hh
// or `operatorX` for an operator function, which has no identifier.
consteval std::string function_display_name(std::meta::info function) {
if (has_identifier(function)) return std::string(identifier_of(function));
return "operator" + std::string(symbol_of(operator_of(function)));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Q: Why do we need operatorX?

Comment thread protocol.hh
// Which operator a thunk exposes for its call syntax. A named interface member
// is reached through its enclosing `member_base`'s named data member and so is
// dispatched through `operator()`; an operator interface member is reached
// directly and uses the operator it declares.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Q: What does 'directly' mean here?

Comment thread protocol.hh
// Widens the EnclosingType pointer to the enclosing protocol/protocol_view
// object, then calls through its stored vtable pointer's matching function
// pointer, passing the viewed/owned object.
R dispatch(Args... args) noexcept(IsNoexcept)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I think we still need operator() on the thunks? Renaming this is misleading.

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