Skip to content

Commit 8aba643

Browse files
committed
Foundation: Add Segment::append overload for types convertible to T
1 parent 1ec566c commit 8aba643

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Libraries/Foundation/Segment.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ struct Segment
6565
/// @brief Appends a Span to the end of the segment
6666
[[nodiscard]] bool append(Span<const T> span);
6767

68+
/// @brief Appends a Span of items convertible to T to the end of the segment
69+
template <typename U>
70+
[[nodiscard]] bool append(Span<const U> span);
71+
6872
/// @brief Moves contents of another segment to the end of this segment
6973
[[nodiscard]] bool appendMove(Segment&& other);
7074

Libraries/Foundation/Segment.inl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ bool SC::Segment<VTable>::append(Span<const T> span)
224224
return false;
225225
}
226226

227+
template <typename VTable>
228+
template <typename U>
229+
[[nodiscard]] bool SC::Segment<VTable>::append(Span<const U> span)
230+
{
231+
for (const U& it : span)
232+
{
233+
if (not push_back(it))
234+
return false;
235+
}
236+
return true;
237+
}
238+
227239
template <typename VTable>
228240
bool SC::Segment<VTable>::appendMove(Segment&& other)
229241
{

0 commit comments

Comments
 (0)