Cppgres
Build Postgres extensions in C++
Loading...
Searching...
No Matches
cppgres::scope_fail< Func > Struct Template Reference

Scope guard that runs the callable only when the scope is left via an exception. More...

#include <guard.hpp>

Public Member Functions

 scope_fail (Func f, const char *warning_message)
 
 scope_fail (const scope_fail &)=delete
 
scope_failoperator= (const scope_fail &)=delete
 
 scope_fail (scope_fail &&)=delete
 
scope_failoperator= (scope_fail &&)=delete
 

Public Attributes

Func func
 
const char * warning_message
 
int uncaught = std::uncaught_exceptions()
 

Detailed Description

template<typename Func>
struct cppgres::scope_fail< Func >

Scope guard that runs the callable only when the scope is left via an exception.

A scope-fail guard (per std::uncaught_exceptions): the destructor compares the number of in-flight exceptions against the count captured at construction and, only when the scope is being unwound by an exception, runs the callable through cppgres::ffi_guard_noexcept — so the cleanup itself never throws, degrading any failure to a WARNING with the given message.


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