Skip to content

C++20 cleanup#8446

Open
osbre wants to merge 5 commits into
LMMS:masterfrom
osbre:cpp20-cleanup
Open

C++20 cleanup#8446
osbre wants to merge 5 commits into
LMMS:masterfrom
osbre:cpp20-cleanup

Conversation

@osbre

@osbre osbre commented Jun 26, 2026

Copy link
Copy Markdown

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:

  • Use structured bindings and range-for loops in place of iterator/index-based loops
  • Replace std::find/find_if/any_of/all_of/sort/unique/fill/upper_bound/min_element/max_element with std::ranges equivalents, using projections where they clarify intent
  • Use std::erase_if in place of the erase-remove_if idiom
  • Replace hand-written comparison operators with defaulted operator<=> in ProjectVersion and PluginIssue
  • Use .contains() / .remove() for associative container lookups

osbre added 5 commits June 26, 2026 07:10
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.
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.

1 participant