Skip to content

Update C++ standard to version 20#1390

Merged
agarny merged 1 commit intocellml:mainfrom
agarny:issue1379
May 7, 2026
Merged

Update C++ standard to version 20#1390
agarny merged 1 commit intocellml:mainfrom
agarny:issue1379

Conversation

@agarny
Copy link
Copy Markdown
Contributor

@agarny agarny commented Apr 27, 2026

Fixes #1379.

Copilot AI review requested due to automatic review settings April 27, 2026 23:50
@agarny agarny requested review from hsorby and nickerso April 27, 2026 23:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/validator.cpp Outdated
@hsorby
Copy link
Copy Markdown
Contributor

hsorby commented Apr 28, 2026

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.

@agarny agarny merged commit 9877026 into cellml:main May 7, 2026
14 checks passed
@agarny agarny deleted the issue1379 branch May 7, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update C++ standard to version 20

4 participants