ZXFoundation™ 26h2
Loading...
Searching...
No Matches
scope_guard.cxxm File Reference

RAII scope guard — executes a cleanup callback on scope exit. More...

Data Structures

class  lib::scope_guard< Fn >
 RAII scope guard — calls fn on destruction unless dismissed. More...

Functions

template<typename Fn>
auto lib::make_scope_guard (Fn &&fn) noexcept -> scope_guard< Fn >
 Factory function — deduces Fn from the argument.

Detailed Description

RAII scope guard — executes a cleanup callback on scope exit.

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ make_scope_guard()

template<typename Fn>
auto lib::make_scope_guard ( Fn && fn) ->scope_guard< Fn >
nodiscardexportnoexcept

Factory function — deduces Fn from the argument.

Usage: auto guard = lib::make_scope_guard([&]{ cleanup(); });