Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zxing-cpp/core/src/Scope.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * Copyright 2020 Axel Waggershauser | |
| 3 */ | |
| 4 // SPDX-License-Identifier: Apache-2.0 | |
| 5 | |
| 6 #pragma once | |
| 7 | |
| 8 #include <utility> | |
| 9 | |
| 10 namespace ZXing { | |
| 11 | |
| 12 /** | |
| 13 * ScopeExit is a trivial helper meant to be later replaced by std::scope_exit from library fundamentals TS v3. | |
| 14 */ | |
| 15 | |
| 16 template <typename EF> | |
| 17 class ScopeExit | |
| 18 { | |
| 19 EF fn; | |
| 20 public: | |
| 21 ScopeExit(EF&& fn) : fn(std::move(fn)) {} | |
| 22 ~ScopeExit() { fn(); } | |
| 23 }; | |
| 24 | |
| 25 template <class EF> | |
| 26 ScopeExit(EF) -> ScopeExit<EF>; | |
| 27 | |
| 28 /** | |
| 29 * The SCOPE_EXIT macro is eliminating the need to give the object a name. | |
| 30 * Example usage: | |
| 31 * SCOPE_EXIT([]{ printf("exiting scope"); }); | |
| 32 */ | |
| 33 | |
| 34 #define SCOPE_EXIT_CAT2(x, y) x##y | |
| 35 #define SCOPE_EXIT_CAT(x, y) SCOPE_EXIT_CAT2(x, y) | |
| 36 #define SCOPE_EXIT const auto SCOPE_EXIT_CAT(scopeExit_, __COUNTER__) = ScopeExit | |
| 37 | |
| 38 } // ZXing | |
| 39 |
