Concept Subspace :: sus :: mem :: CloneFrom

template <class T>
concept CloneFrom
requires
sus::mem::Clone<T>
(Copy<T> && !__private::HasCloneFromMethod<
                     std::remove_const_t<std::remove_reference_t<T>>>) ||
     (!Copy<T> && __private::HasCloneFromMethod<
                      std::remove_const_t<std::remove_reference_t<T>>>)

Determines if T has an optimized path T::clone_from(const T&) that can be used from clone_into.

This is largely an implementation detail of clone_into as it can be called on all types that satisfy Clone. But it can be useful for verifying in a static assert that a type is written correctly and the optimization will be used.

Evaluates to true if the type is Copy, as the copy assignment operator acts like clone_from method. It return false if the type is Copy and also has a clone_from method, as it becomes ambiguous and is thus invalid.