Skip to content

addon: add const overloads for multipart_t front/back#682

Merged
gummif merged 2 commits intozeromq:masterfrom
mberk-yilmaz:master
Mar 18, 2026
Merged

addon: add const overloads for multipart_t front/back#682
gummif merged 2 commits intozeromq:masterfrom
mberk-yilmaz:master

Conversation

@mberk-yilmaz
Copy link
Contributor

This PR focuses on adding const-qualified accessors to the multipart_t class.

Current State

Currently the front() and back() methods return a const message_t&, even when called on objects that are not const. While a standard STL-like design usually provides a version that returns a mutable message_t& for non-const objects, this PR does not change that logic yet.

What’s New?

This update specifically adds:
const message_t &front() const
const message_t &back() const

Rationale

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.

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.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 23242599549

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 87.918%

Totals Coverage Status
Change from base Build 23046622562: 0.02%
Covered Lines: 946
Relevant Lines: 1076

💛 - Coveralls

@gummif gummif merged commit 4f423e0 into zeromq:master Mar 18, 2026
11 checks passed
@gummif
Copy link
Member

gummif commented Mar 18, 2026

Thanks

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.

3 participants