SpECTRE  v2024.09.29
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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);
An object that calls a functor when it goes out of scope.
Definition: CleanupRoutine.hpp:12

The documentation for this class was generated from the following file: