refactor: consolidate Dash-specific utils between C++23 polyfills (util/std23.h) and helpers (util/helpers.h)#7098
Merged
PastaPastaPasta merged 12 commits intodashpay:developfrom Mar 12, 2026
Merged
Conversation
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.
Motivation
The upgrade to C++20 (dash#6380) allowed us to drop most of our polyfills meant as bridge from C++17, though we still have utils beyond the ones inherited from upstream that have accumulated over time, most of them, seeking to bridge C++23 features while others are entirely custom or serve as convenience functions or thin wrappers.
Some of them include:
util/ranges.h(mostly now an alias tostd::rangesafter C++20 migration except forfind_if_opt, which is custom)util/irange.h(equivalent tostd::views::iota, introduced in C++20)util/enumerate.h(equivalent tostd::views::enumerate, introduced in C++23)util/underlying.h(equivalent tostd::to_underlying, introduced in C++23)util/pointer.h(customstd::shared_ptrhelper)This pull requests compacts all of those helpers into two files:
util/helpers.h(custom helpers, replacingutil/irange.h,util/pointer.h,util/ranges.h)util/std23.h(polyfill for C++23, replacingutil/enumerate.handutil/underlying.h)And additionally, introduces additional capabilities utilised in Dash-specific code:
std23::ranges::contains(equivalent tostd::ranges::contains)std23::ranges::fold_left(equivalent tostd::ranges::fold_left)util::to_string(bool)(equivalent tovalue ? "true" : "false")Additional Information
ToUnderlying()needed to be renamed toto_underlying()to match with the standard library naming so we can discontinue the polyfill easily when we migrate to C++23 by just goings/std23/std/g.While
iranges::rangeis equivalent tostd::views::iota, the latter requires both min and max to be of the same type but literal0has a type incompatible withsize_t, requiringsize_t{0}to compile. As propagation of these changes for each instance is bothersome,util::irange()exists as a thin wrapper that wraps the literal around the type formaxBreaking Changes
None expected.
Checklist