Repository navigation
chuds: check body with a concept - #11
Merged
Merged
Conversation
adds chuds::WireBody concept that defines what make_message and body_as can accept. ie, opt-in marker, trivially copyable, standard layout, size is less than kMaxBody, no padding, no pointer the padding/pointer rule is new, and is something we were missing rename chuds_wire_body to is_chuds_wire_body to match other c++ concepts added tests to assert WireBody works properly, and fails to compile
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Member
Author
|
:/ |
danielsapiary
approved these changes
Oct 17, 2026
danielsapiary
left a comment
There was a problem hiding this comment.
Small and well-documented and reasoned. Nice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
adds
chuds::WireBodyconcept that defines whatmake_messageandbody_ascan accept. ie, opt-in marker, trivially copyable, standard layout, size is at most
kMaxBody, no padding, no pointerpreviously we would just require it to be is_standard_layout_v and is_trivially_copyable_v, as
has_unique_object_representationsdoesn't work for floats.we now have some compiler magic:
at compile time, we default construct an instance of
T, and loop over each byte of it. we cannotbit_castpointers at compile time. we also can't read a byte with an indeterminate at compile time. so, both pointers and padding now properly cause compile errorsrename
chuds_wire_bodytois_chuds_wire_bodyto read as a yes/no flagadded tests to assert
WireBodyworks properly, and that bad bodies fail to compile throughmake_messageandbody_asWhy?
handles more cases that should be handled: pointers and padding. it would previously cause garbage data to be sent.
follows idiomatic c++
Verification Evidence
the tests pass.
we assert that the
WireBodyconcept works for the shapes of structs that we want it to support, and it properly fails for the shapes that it shouldnt' work for.we also test that things that should fail to compile do indeed fail to compile
ci also passes.