Update C++ standard to version 20#1390
Merged
agarny merged 1 commit intocellml:mainfrom May 7, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates libCellML’s build configuration and implementation code to require and take advantage of C++20, addressing issue #1379.
Changes:
- Bump the core library and related targets (tests + JS bindings) to compile with C++20.
- Modernise container/algorithm usage across the codebase (e.g.,
std::ranges::*,contains,starts_with,std::erase(_if)). - Simplify and modernise some internal data structures (e.g., cached equivalence keying in
AnalyserModel).
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/api_headers/api_header_test.in.cmake | Update API header inclusion test target to C++20. |
| src/CMakeLists.txt | Raise exported compile features for cellml and cellml_debug_utilities to cxx_std_20. |
| src/bindings/javascript/CMakeLists.txt | Update JS bindings target to C++20 to match core library requirement. |
| src/variable.cpp | Switch equivalent-variable searches/cleanup to C++20 ranges + std::erase_if. |
| src/validator.cpp | Replace various std::* algorithms/string-prefix checks with C++20 ranges + starts_with/contains/try_emplace. |
| src/utilities.cpp | Modernise helpers using contains and std::ranges::all_of, plus minor construction/emplace cleanups. |
| src/units.cpp | Move unit lookup to std::ranges::find_if. |
| src/printer.cpp | Use braced pair construction and std::ranges::find_if/find for map building. |
| src/parser.cpp | Canonicalise connection/variable pairs and use std::ranges::find for uniqueness checks. |
| src/model.cpp | Convert unit/import requirement lookups to std::ranges::*. |
| src/importer.cpp | Use contains, emplace, and iterator-based access to simplify library/import tracking. |
| src/generatorvariabletracker.cpp | Use contains when tracking analyser variables. |
| src/generator.cpp | Replace manual erase/find patterns with std::erase and std::ranges::find. |
| src/componententity.cpp | Convert component lookup to std::ranges::find_if. |
| src/component.cpp | Convert variable/reset lookup to std::ranges::find_if. |
| src/annotator.cpp | Use emplace/contains to simplify ID list maintenance. |
| src/analysermodel_p.h | Replace custom key struct with std::pair<uintptr_t, uintptr_t> and a hash functor. |
| src/analysermodel.cpp | Use std::minmax and the new key type for cached equivalence lookup. |
| src/analyserexternalvariable.cpp | Convert dependency searches to std::ranges::find_if. |
| src/analyserequation.cpp | Use std::erase_if for staging dependency removal. |
| src/analyser.cpp | Broad conversion from classic algorithms to ranges + container helpers (contains, std::erase(_if)). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9bb3b05 to
6f0d6b4
Compare
Contributor
|
In this PR all I am really only expecting to see is the changes to the two CMakeLists.txt files updating to C++ 20 standard. I don’t see the other changes that take advantage of this upgrade as part of this PR. The take advantage of the C++ 20 standard changes belong in a separate PR. |
hsorby
approved these changes
Apr 28, 2026
nickerso
approved these changes
May 7, 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.
Fixes #1379.