The Gaudi Framework
master (37c0b60a)
finally.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2019 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
#include <utility>
12
//
13
// make it possible to execute an action at the exit of a scope
14
//
15
// auto f = finally( [](){ std::cout << "end of scope!" << std::endl; } );
16
//
17
// the above will execute the provided callable when f goes out of scope,
18
// i.e. the 'current' scope ends.
19
20
template
<
typename
F>
21
struct
final_action
{
22
F
act
;
23
final_action
( F&&
act
) :
act
{
std::move
(
act
) } {}
24
final_action
(
final_action
&& ) =
default
;
25
~final_action
() {
act
(); }
26
};
27
28
template
<
typename
F>
29
final_action<F>
finally
( F&& act ) {
30
return
{ std::forward<F>( act ) };
31
}
std::move
T move(T... args)
final_action::final_action
final_action(final_action &&)=default
final_action::~final_action
~final_action()
Definition:
finally.h:25
final_action::final_action
final_action(F &&act)
Definition:
finally.h:23
final_action
Definition:
finally.h:21
final_action::act
F act
Definition:
finally.h:22
GaudiKernel
include
GaudiKernel
finally.h
Generated on Thu Dec 19 2024 15:35:01 for The Gaudi Framework by
1.8.18