Concept Subspace :: sus :: construct :: From
template <class ToType, class FromType>concept From
requires
requires(FromType&& from) { { ToType::from(::sus::forward<FromType>(from)) } -> std::same_as<ToType>;}
A concept that indicates ToType can be constructed from a FromType, via
ToType::from(FromType).
This concept is rarely used directly, instead prefer to use the
sus::construct::Into concept, as it also supports identity
transformations.
When a type is From<T, O>, it is also Into<O, T>. Then a variable o of
type O can be explicitly converted to T, with type deduction, via
sus::into(o).
It is only possible to satisfy this concept for ToType that is not a
reference, as it needs to be able to construct ToType.
Arrays
It's possible to convert from an array, in which case From<T, O(&)[]> is
satisfied. To do so, implement from() as a templated method,
with a size_t template parameter for the size of the incoming array. For
example:
// sus::construct::From<Slice<T>, O[]> trait.
template <size_t N>
static constexpr inline Slice from(T (&data)[N]) {
return Slice(data, N);
}