From 0f2cf531f705d370321843e5ba9135b2ebdb5d19 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 17 May 2020 16:31:57 +0100 Subject: style(3p/nix): Reformat project in Google C++ style Reformatted with: fd . -e hh -e cc | xargs clang-format -i --- third_party/nix/src/libutil/lazy.hh | 47 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 26 deletions(-) (limited to 'third_party/nix/src/libutil/lazy.hh') diff --git a/third_party/nix/src/libutil/lazy.hh b/third_party/nix/src/libutil/lazy.hh index d073e486c2eb..9807b7540620 100644 --- a/third_party/nix/src/libutil/lazy.hh +++ b/third_party/nix/src/libutil/lazy.hh @@ -12,37 +12,32 @@ namespace nix { thread-safe way) on first use, that is, when var() is first called. If the initialiser code throws an exception, then all subsequent calls to var() will rethrow that exception. */ -template -class Lazy -{ +template +class Lazy { + typedef std::function Init; - typedef std::function Init; + Init init; - Init init; + std::once_flag done; - std::once_flag done; + T value; - T value; + std::exception_ptr ex; - std::exception_ptr ex; + public: + Lazy(Init init) : init(init) {} -public: - - Lazy(Init init) : init(init) - { } - - const T & operator () () - { - std::call_once(done, [&]() { - try { - value = init(); - } catch (...) { - ex = std::current_exception(); - } - }); - if (ex) std::rethrow_exception(ex); - return value; - } + const T& operator()() { + std::call_once(done, [&]() { + try { + value = init(); + } catch (...) { + ex = std::current_exception(); + } + }); + if (ex) std::rethrow_exception(ex); + return value; + } }; -} +} // namespace nix -- cgit 1.4.1