Function Subspace :: sus :: mem :: take

template <class T>
auto take(T& t) -> T
requires
sus::mem::Move<T>
sus::construct::Default<T>
std::is_final_v<T>

Moves from t and constructs a new T in its place. Returns the old value of t.

Requires that the type is final because calling take() on a base class could lead to Undefined Behaviour if the now-reconstructed object is accessed without std::launder thereafter, as replacing a subclass with the base class would change the underlying storage.