Skip to content

Commit

Permalink
Fix the uniqueness detection in the finalizer.
Browse files Browse the repository at this point in the history
  • Loading branch information
timspainNERSC committed Oct 1, 2024
1 parent 374bd7a commit b0c4d35
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/Finalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ bool Finalizer::contains(const FinalFn& fn)
{
auto& fns = functions();
for (const auto& stored : fns) {
if (stored.target<void()>() == fn.target<void()>())
// Compare function pointer addresses
if (stored.target<FnType*>() == fn.target<FnType*>())
return true;
}
return false;
Expand Down
3 changes: 2 additions & 1 deletion core/src/include/Finalizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace Nextsim {

class Finalizer {
public:
using FinalFn = std::function<void()>;
using FnType = void();
using FinalFn = std::function<FnType>;
/*!
* Adds a function to be called at finalization. Functions are ordered last-in, first out.
* @param fn The function to be added. Must have void() signature.
Expand Down

0 comments on commit b0c4d35

Please # to comment.