![]() |
|
|||
File indexing completed on 2025-02-21 10:00:29
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #include <utility> 0012 // 0013 // make it possible to execute an action at the exit of a scope 0014 // 0015 // auto f = finally( [](){ std::cout << "end of scope!" << std::endl; } ); 0016 // 0017 // the above will execute the provided callable when f goes out of scope, 0018 // i.e. the 'current' scope ends. 0019 0020 template <typename F> 0021 struct final_action { 0022 F act; 0023 final_action( F&& act ) : act{ std::move( act ) } {} 0024 final_action( final_action&& ) = default; 0025 ~final_action() { act(); } 0026 }; 0027 0028 template <typename F> 0029 final_action<F> finally( F&& act ) { 0030 return { std::forward<F>( act ) }; 0031 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |