From 4ce702a7439d7afda843c6eafbab47499a385df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 4 May 2025 17:46:56 +0100 Subject: [PATCH] src: remove NonCopyableMaybe I added this class in 823d86c47ce15fba8875fcebd412593b02aab362 in 2018 when we did not yet use `std::optional`. The last uses were removed in 5b9bf39b47afcf26aaad810eec2ba8bdff904d4c, so remove it. Refs: https://github.com/nodejs/node/pull/24234 Refs: https://github.com/nodejs/node/pull/55368 --- src/util.h | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/src/util.h b/src/util.h index 7e575605cb7364..7527ec0909cefd 100644 --- a/src/util.h +++ b/src/util.h @@ -656,38 +656,6 @@ struct MallocedBuffer { MallocedBuffer& operator=(const MallocedBuffer&) = delete; }; -template -class NonCopyableMaybe { - public: - NonCopyableMaybe() : empty_(true) {} - explicit NonCopyableMaybe(T&& value) - : empty_(false), - value_(std::move(value)) {} - - bool IsEmpty() const { - return empty_; - } - - const T* get() const { - return empty_ ? nullptr : &value_; - } - - const T* operator->() const { - CHECK(!empty_); - return &value_; - } - - T&& Release() { - CHECK_EQ(empty_, false); - empty_ = true; - return std::move(value_); - } - - private: - bool empty_; - T value_; -}; - // Test whether some value can be called with (). template struct is_callable : std::is_function { };