Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
src: remove NonCopyableMaybe
I added this class in 823d86c in 2018
when we did not yet use `std::optional`. The last uses were removed in
5b9bf39, so remove it.

Refs: #24234
Refs: #55368
  • Loading branch information
tniessen committed May 4, 2025
commit 4ce702a7439d7afda843c6eafbab47499a385df6
32 changes: 0 additions & 32 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,38 +656,6 @@ struct MallocedBuffer {
MallocedBuffer& operator=(const MallocedBuffer&) = delete;
};

template <typename T>
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 <typename T, typename = void>
struct is_callable : std::is_function<T> { };
Expand Down
Loading