Repository navigation
Use C++20 iterator concepts in our format headers - #497
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the format headers in libbroker by replacing traditional template metaprogramming patterns with C++20 concepts, improving code clarity and type safety. The changes introduce custom iterator concepts and leverage standard library concepts for more expressive template constraints.
- Introduces three new concepts in
type_traits.hh:byte_output_iterator,char_output_iterator, andarithmetic - Replaces
class OutItertemplate parameters with concept-constrained parameters across all format headers - Converts
requiresclauses and SFINAE patterns to more concise concept-based constraints (e.g.,std::same_as<data>,std::integral) - Updates iterator template parameters from generic names to standard concepts (
std::input_iterator,std::sentinel_for)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
libbroker/broker/detail/type_traits.hh |
Adds forward declaration for caf::byte and defines three new concepts for output iterators and arithmetic types |
libbroker/broker/format/txt.hh |
Replaces unconstrained template parameters with detail::char_output_iterator, std::integral, and std::same_as concepts; adds <concepts> and <iterator> includes |
libbroker/broker/format/json.hh |
Applies similar concept constraints for output iterators and integral types; adds explicit include of type_traits.hh; changes iterator parameter names from ForwardIterator to Iterator with std::input_iterator concept |
libbroker/broker/format/bin.hh |
Replaces template constraints with detail::byte_output_iterator, std::unsigned_integral, std::same_as, and detail::arithmetic concepts; removes unused <vector> include |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Neverlord
marked this pull request as ready for review
December 14, 2025 09:12
timwoj
approved these changes
Jan 20, 2026
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.
Modernize our format headers with more C++20 concepts.