Skip to content

Commit 7751e0e

Browse files
committed
box::make
1 parent 6dbf0cb commit 7751e0e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

rpp/box.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ struct Box {
5353
}
5454
}
5555

56+
template<typename... Args>
57+
[[nodiscard]] static Box make(Args&&... args) noexcept {
58+
Box ret;
59+
auto data = A::template make<Storage<T>>();
60+
new(data->data()) T{forward<Args>(args)...};
61+
ret.data_ = reinterpret_cast<T*>(data);
62+
return ret;
63+
}
64+
5665
template<Scalar_Allocator R = P>
5766
[[nodiscard]] Box<T, R> clone() const noexcept
5867
requires(Clone<T> || Copy_Constructable<T>)

0 commit comments

Comments
 (0)