Skip to content

Commit

Permalink
Containers: Help type deduction for toSpan() and toSpanConst()
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagghiu committed Aug 25, 2024
1 parent a7c64cc commit 9a0a5aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Libraries/Containers/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ struct SC::Array

/// @brief Returns a Span wrapping the entire of current array
/// @return a Span wrapping the entire of current array
[[nodiscard]] Span<const T> toSpanConst() const SC_LANGUAGE_LIFETIME_BOUND { return {items, size()}; }
[[nodiscard]] Span<const T> toSpanConst() const SC_LANGUAGE_LIFETIME_BOUND { return Span<const T>(items, size()); }

/// @brief Returns a Span wrapping the entire of current array
/// @return a Span wrapping the entire of current array
[[nodiscard]] Span<T> toSpan() SC_LANGUAGE_LIFETIME_BOUND { return {items, size()}; }
[[nodiscard]] Span<T> toSpan() SC_LANGUAGE_LIFETIME_BOUND { return Span<T>(items, size()); }

/// @brief Access item at index. Bounds checked in debug.
/// @param index index of the item to be accessed
Expand Down Expand Up @@ -370,7 +370,7 @@ SC::Array<T, N>::Array(const Array& other)
{
segmentHeader.sizeBytes = 0;
segmentHeader.capacityBytes = sizeof(T) * N;
(void)append({other.items, other.size()});
(void)append(other.toSpanConst());
}

template <typename T, int N>
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Containers/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ struct SC::Vector

/// @brief Returns a Span wrapping the entire of current vector
/// @return a Span wrapping the entire of current vector
[[nodiscard]] Span<const T> toSpanConst() const SC_LANGUAGE_LIFETIME_BOUND { return {items, size()}; }
[[nodiscard]] Span<const T> toSpanConst() const SC_LANGUAGE_LIFETIME_BOUND { return Span<const T>(items, size()); }

/// @brief Returns a Span wrapping the entire of current vector
/// @return a Span wrapping the entire of current vector
[[nodiscard]] Span<T> toSpan() SC_LANGUAGE_LIFETIME_BOUND { return {items, size()}; }
[[nodiscard]] Span<T> toSpan() SC_LANGUAGE_LIFETIME_BOUND { return Span<T>(items, size()); }

/// @brief Access item at index. Bounds checked in debug.
/// @param index index of the item to be accessed
Expand Down

0 comments on commit 9a0a5aa

Please sign in to comment.