addon: add const overloads for multipart_t front/back#682
Merged
gummif merged 2 commits intozeromq:masterfrom Mar 18, 2026
Merged
addon: add const overloads for multipart_t front/back#682gummif merged 2 commits intozeromq:masterfrom
gummif merged 2 commits intozeromq:masterfrom
Conversation
Add const-qualified overloads for multipart_t::front() and back() in `zmq_addon.hpp`. Note on API shape: - In a container-style API, non-const overloads would typically return `message_t&`. - This change intentionally preserves existing non-const return types (`const message_t&`) for backward-compatibility and to avoid broadening mutability semantics in this PR. Also extend `tests/multipart.cpp` with compile-time and runtime checks for const/non-const access paths. No behavioral change intended.
Pull Request Test Coverage Report for Build 23242599549Details
💛 - Coveralls |
Member
|
Thanks |
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.
This PR focuses on adding
const-qualifiedaccessors to themultipart_tclass.Current State
Currently the
front()andback()methods return aconst message_t&, even when called on objects that are not const. While a standard STL-like design usually provides a version that returns a mutablemessage_t&for non-const objects, this PR does not change that logic yet.What’s New?
This update specifically adds:
const message_t &front() constconst message_t &back() constRationale
Backward Compatibility: It preserves existing behavior and mutability expectations.
Low Risk: The scope is kept minimal to ensure stability.
Separation of Concerns: It avoids mixing basic const-access improvements with larger changes to the mutability policy.
If the maintainers prefer to have mutable-return overloads (returning
message_t&), I can propose those in a separate, more focused follow-up PR.