Concept Subspace :: sus :: collections :: Concat

template <class T>
concept Concat
requires
requires(const T& t, const ::sus::num::usize& cap) {
  // Concat between types of T must report their lengths.
  { t.len() } -> std::same_as<::sus::num::usize>;
  // The Concat between types of T produces this type.
  typename T::ConcatOutputType;
  // The output type can be constructed with a capacity.
  {
    T::ConcatOutputType::with_capacity(cap)
  } -> std::same_as<typename T::ConcatOutputType>;
  // The output type can be extended by each object of type T.
  requires requires(typename T::ConcatOutputType & collection) {
    { t.concat_into(collection) } -> std::same_as<void>;
  };
}

Types that support being flattened and concatenated together into a collection.

For example, Slice is Concat, which allows a Slice<Slice<U>> to be concatenated into a Slice<U> of all the original elements. This concept requires T to provide concat_into(T::ConcatOutputType&) that does the concatenation.

TODO: String should satisfy Concat as well.