Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Added default/empty constructor for borrowed_ptr.
Browse files Browse the repository at this point in the history
  • Loading branch information
benh committed Jul 6, 2020
1 parent 1183b88 commit 47ad24d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions include/stout/borrowed_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ template <typename T>
class borrowed_ptr
{
public:
borrowed_ptr() {}

template <typename U, typename F>
borrowed_ptr(U* u, F&& f)
: t_(u, std::forward<F>(f))
{}
: t_(u, std::forward<F>(f)) {}

// NOTE: requires 'Deleter' to be copyable (for now).
template <typename U, typename Deleter, typename F>
Expand All @@ -23,17 +24,16 @@ class borrowed_ptr
u.release(),
[deleter = u.get_deleter(), f = std::forward<F>(f)](auto* u) {
f(std::unique_ptr<U, Deleter>(u, deleter));
})
{}
}) {}

// NOTE: requires 'Deleter' to be copyable (for now).
template <typename U, typename Deleter>
borrowed_ptr(std::unique_ptr<U, Deleter>&& u)
: borrowed_ptr(std::move(u), [](auto&&) {})
{}
: borrowed_ptr(std::move(u), [](auto&&) {}) {}

template <typename H>
friend H AbslHashValue(H h, const borrowed_ptr& that) {
friend H AbslHashValue(H h, const borrowed_ptr& that)
{
return H::combine(std::move(h), that.t_);
}

Expand Down

0 comments on commit 47ad24d

Please sign in to comment.