17 std::unique_ptr<T> inner;
22 explicit box_ptr(std::unique_ptr<T> p)
25 assert(inner !=
nullptr);
29 using pointer =
typename std::unique_ptr<T>::pointer;
31 inline typename std::add_lvalue_reference<T>::type operator*()
const noexcept
36 inline pointer operator->()
const noexcept
41 inline pointer get()
const noexcept
65 template<
typename Other>
67 requires std::convertible_to<typename box_ptr<Other>::pointer, pointer> &&(!std::is_array_v<Other>)
69 : inner(std::move(other.inner))
71 other.inner =
nullptr;
76 std::unique_ptr<T> take() &&
78 return std::move(inner);
83requires std::equality_comparable<T>
84bool operator==(box_ptr<T>
const & x, box_ptr<T>
const & y)
93requires std::equality_comparable<T>
94bool operator!=(box_ptr<T>
const & x, box_ptr<T>
const & y)
99#define MAKE_COMPARISON(OP) \
100 template<typename T> \
101 requires std::totally_ordered<T> \
102 bool operator OP(box_ptr<T> const & x, box_ptr<T> const & y) \
112#undef MAKE_COMPARISON
115requires std::three_way_comparable<T> std::compare_three_way_result_t<T, T>
116operator<=>(box_ptr<T>
const & x, box_ptr<T>
const & y)
121template<
typename T,
typename... Args>
122inline box_ptr<T> make_box_ptr(Args &&... args)
static box_ptr< T > unsafeFromNonnull(std::unique_ptr< T > p)
Definition box_ptr.hh:49
box_ptr(box_ptr< Other > &&other) noexcept
Definition box_ptr.hh:68