Comparison between two protocol objects
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- cpp
- Domain
- backend-api-design
Research direction
The issue names no files or tests. Start by reading #439 and #208, then trace the protocol and protocol_view comparison design described here; done means the open semantic, type-identity, mismatch, valueless, conversion, and scope questions have a decided specification.
Written by the indexing model from the issue text.
Description
#439 forwards member comparisons with an operand of another type and rejects any comparison on an interface I with an operand of type I. The idiomatic declaration is therefore free to be given a meaning:
struct I {
bool operator==(const I&) const = default;
auto operator<=>(const I&) const = default;
};
protocol<I> p(A{}), q(B{});
p == q;
Open questions:
- Meaning. Does
const I&stand for the conforming type itself? Conformance would then meanChasoperator==(const C&) const, andprotocol<I>would getoperator==(const protocol&) const. Should that apply only to defaulted comparisons, or to user-declared ones as well? - Type identity. The thunk must know that both operands hold the same
Cbefore it casts.typeidneeds RTTI. The vtable address is cheap but not reliably unique across shared libraries. - Mismatched types.
==can returnfalse.<=>could returnpartial_ordering::unordered(which rules outstrong_orderingon the interface), order bytype_index(an unspecified order), or throw as Boost.TypeErasure does.std::polymorphicomits comparison for this reason. - Valueless operands. See #208.
protocol_view. Does it compare the referenced objects or the pointers? Should mixedprotocol/protocol_viewcomparison be allowed?- Conversions between interfaces. What does a comparison that names the conforming type do when a protocol converts to another interface?
- Scope. Does "own type" stop at comparisons, or extend to members such as
void merge(const I&)andI clone() const?
An alternative is a library opt-in (a tag base or trait) in place of rewriting const I&. That works against the design's premise that the interface struct is the whole specification.
- Dominant language
- C++
- Stars
- 11
- Forks
- 4
- Avg merge
- 15h 44m
- Merged PRs (30d)
- 145
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jbcoe/cc-protocol
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jbcoe/cc-protocol#407 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
jbcoe/cc-protocol#194 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
jbcoe/cc-protocol#453 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jbcoe/cc-protocol#452 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
jbcoe/cc-protocol#451 ·
All issues in jbcoe/cc-protocol
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Sensor initialization takes very long when `--initial-sim-time` is set to current UNIX timestamp Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gazebosim/gz-sensors#662 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LadybirdBrowser/ladybird#12123 ·