Skip to content

Commit

Permalink
wrapped: comparison to nullptr, default ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Aug 31, 2024
1 parent b27c021 commit bfef196
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/cista/memory_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ using memory_holder = std::variant<buf<mmap>, buffer, byte_buf>;

template <typename T>
struct wrapped {
wrapped() = default;
wrapped(memory_holder mem, T* el) : mem_{std::move(mem)}, el_{el} {
el_.self_allocated_ = false;
}
explicit wrapped(raw::unique_ptr<T> el) : el_{std::move(el)} {}

friend bool operator==(wrapped const& x, std::nullptr_t) {
return x.el_ == nullptr;
}

T* get() const noexcept { return el_.get(); }
T* operator->() noexcept { return el_.get(); }
T const* operator->() const noexcept { return el_.get(); }
Expand Down

0 comments on commit bfef196

Please sign in to comment.