-
-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ code cleanup and modernization #1452
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1452 +/- ##
==========================================
- Coverage 71.02% 69.63% -1.40%
==========================================
Files 369 373 +4
Lines 55558 55769 +211
Branches 18378 18295 -83
==========================================
- Hits 39462 38833 -629
- Misses 13607 14480 +873
+ Partials 2489 2456 -33
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this extensive cleanup, @speth! The changes are straight-forward and all look good to me. I definitely like the unpacking of pairs, which definitely makes code easier to follow!
I will approve once the remaining Intel compiler failure is resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@speth ... on a related note: what are differences between boost's |
Yes, |
If I'm not mistaken, the |
Also use make_shared more consistently
Depending on the output times given to Reactor.advance, specified limits on the change in one or more state variables can be exceeded by a wide margin. See Cantera#1453
3410095
to
d63895c
Compare
Since we no longer need to "hide" the Boost usage, we can make the std::any member of AnyValue a regular member variable rather than a pointer, which simplifies a few things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the updates!
This is some wide-ranging cleanup of the code to make use of some features from the modern C++ to make the code simpler and more readable.
Given the large number of files this touches, I know there will be a few merge conflicts, so I'm happy to try getting a couple of existing PRs merged ahead of this one and deal with those conflicts here.
Changes proposed in this pull request
if constexpr
(C++17) to greatly simplify the implementation ofMultiRate
methods that depend on whether or not the rate class implements specific methods likeupdateFromStruct
std::filesystem
(C++17) to avoid OS-specific implementations ofget_modified_time
std::pair
/std::tuple
and improve readability (for example,for (auto& [a, b] : some_map)
)make_unique
(C++14) andmake_shared
(C++11) to reduce usage of barenew
.ClassName() = default;
to implement trivial constructors and similar for destructors (C++11)using
statementsstd::any
(C++17) instead ofboost::any
to implementAnyValue
. Since we no longer need to hide theboost
type behind aunique_ptr
, this simplifies the implementation ofAnyValue
slightly and eliminates an extra memory allocation for everyAnyValue
object.Checklist
scons build
&scons test
) and unit tests address code coverage