diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/generic/scope.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/scope.h')
-rw-r--r-- | util/generic/scope.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/util/generic/scope.h b/util/generic/scope.h index b2c33af61e..e03d86bcde 100644 --- a/util/generic/scope.h +++ b/util/generic/scope.h @@ -10,14 +10,14 @@ namespace NPrivate { class TScopeGuard { public: TScopeGuard(const F& function) - : Function_{function} - { - } + : Function_{function} + { + } TScopeGuard(F&& function) - : Function_{std::move(function)} - { - } + : Function_{std::move(function)} + { + } TScopeGuard(TScopeGuard&&) = default; TScopeGuard(const TScopeGuard&) = default; @@ -26,17 +26,17 @@ namespace NPrivate { Function_(); } - private: - F Function_; - }; - + private: + F Function_; + }; + struct TMakeGuardHelper { template <class F> - TScopeGuard<F> operator|(F&& function) const { + TScopeGuard<F> operator|(F&& function) const { return std::forward<F>(function); } - }; -} + }; +} // \brief `Y_SCOPE_EXIT(captures) { body };` // @@ -46,7 +46,7 @@ namespace NPrivate { // @note expects `body` to provide no-throw guarantee, otherwise whenever an exception // is thrown and leaves the outermost block of `body`, the function `std::terminate` is called. // @see http://drdobbs.com/184403758 for detailed motivation. -#define Y_SCOPE_EXIT(...) const auto Y_GENERATE_UNIQUE_ID(scopeGuard) Y_DECLARE_UNUSED = ::NPrivate::TMakeGuardHelper{} | [__VA_ARGS__]() mutable -> void +#define Y_SCOPE_EXIT(...) const auto Y_GENERATE_UNIQUE_ID(scopeGuard) Y_DECLARE_UNUSED = ::NPrivate::TMakeGuardHelper{} | [__VA_ARGS__]() mutable -> void // \brief `Y_DEFER { body };` // @@ -62,4 +62,4 @@ namespace NPrivate { // ... try handle `item` ... // ok = true; // \endcode -#define Y_DEFER Y_SCOPE_EXIT(&) +#define Y_DEFER Y_SCOPE_EXIT(&) |