C++20 cleanup#8446
Open
osbre wants to merge 5 commits into
Open
Conversation
Replace hand-written comparison operators with a defaulted `operator<=>`: - ProjectVersion: collapse six free comparison operators into a single member `operator<=>` plus an equality operator. - PluginIssue: drop the explicit `operator==`/`operator<`. The default lexicographic comparison over (m_issueType, m_info) matches the prior behaviour exactly.
Replace the erase + `std::remove_if` idiom in StepRecorder and Song with `std::erase_if`.
Convert `std::find`, `find_if`, `any_of`, `all_of`, `sort`, `unique`, `fill`,
`upper_bound`, and `min/max_element` call sites across core, gui, and tracks
to their `std::ranges` equivalents, using projections (`&Type::member`) in
place of trivial accessor lambdas where it clarifies intent.
Also:
- Collapse `iter = find(...); if (iter != end()) { ... }` pairs into
`if (auto iter = ranges::find(...); iter != end()) { ... }` where the
iterator isn't reused afterwards.
- `ConfigManager::isFavoriteItem`: replace `find_if(...) != end()` with a
direct `std::ranges::any_of` call.
Some sites are intentionally left on `std::sort` (Qt containers and
`QList<QAction*>` don't satisfy libc++'s `random_access_iterator` concept
for ranges).
- LinkedModelGroups::foreach_model: cbegin/cend index loops replaced with a structured-binding range-for over the underlying `std::map`. - MidiWinMM: ConstIterator loop over the input port list collapsed to a range-for that names the port directly. - EffectSelectDialog: same treatment for the EffectKeyList loop.
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.
I've used Claude Code (Opus model) to find non-breaking C++20 modernization opportunities. Curious if you'd find it useful or rather distracting.
Current list of changes in separate commits:
std::find/find_if/any_of/all_of/sort/unique/fill/upper_bound/min_element/max_elementwithstd::rangesequivalents, using projections where they clarify intentstd::erase_ifin place of the erase-remove_ifidiomoperator<=>inProjectVersionandPluginIssue.contains()/.remove()for associative container lookups