The Gaudi Framework
master (181af51f)
Loading...
Searching...
No Matches
finally.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#pragma once
12
13
#include <utility>
14
//
15
// make it possible to execute an action at the exit of a scope
16
//
17
// auto f = finally( [](){ std::cout << "end of scope!" << std::endl; } );
18
//
19
// the above will execute the provided callable when f goes out of scope,
20
// i.e. the 'current' scope ends.
21
22
template
<
typename
F>
23
struct
final_action
{
24
F
act
;
25
final_action
( F&&
act
) :
act
{
std
::move(
act
) } {}
26
final_action
(
final_action
&& ) =
default
;
27
~final_action
() {
act
(); }
28
};
29
30
template
<
typename
F>
31
final_action<F>
finally
( F&& act ) {
32
return
{ std::forward<F>( act ) };
33
}
std
STL namespace.
final_action
Definition
finally.h:23
final_action::final_action
final_action(final_action &&)=default
final_action::final_action
final_action(F &&act)
Definition
finally.h:25
final_action::act
F act
Definition
finally.h:24
final_action::~final_action
~final_action()
Definition
finally.h:27
GaudiKernel
include
GaudiKernel
finally.h
Generated on Wed Oct 8 2025 09:53:37 for The Gaudi Framework by
1.13.1