SpECTRE  v2026.04.01
Loading...
Searching...
No Matches
CleanupRoutine< F > Class Template Reference

An object that calls a functor when it goes out of scope. More...

#include <CleanupRoutine.hpp>

Public Member Functions

 CleanupRoutine (F routine)
 CleanupRoutine (const CleanupRoutine &)=delete
 CleanupRoutine (CleanupRoutine &&)=delete
CleanupRoutineoperator= (const CleanupRoutine &)=delete
CleanupRoutineoperator= (CleanupRoutine &&)=delete

Detailed Description

template<typename F>
class CleanupRoutine< F >

An object that calls a functor when it goes out of scope.

int x = 1;
try {
const CleanupRoutine cleanup = [&x]() { x = 3; };
x = 2;
if (do_throw) {
throw std::exception{};
}
} catch (const std::exception&) {
CHECK(x == 3);
}
CHECK(x == 3);

The documentation for this class was generated from the following file:
  • src/Utilities/CleanupRoutine.hpp