AK: Add a comparison operator for Utf32View

This commit is contained in:
Timothy Flynn 2024-10-18 17:19:57 -04:00 committed by Andreas Kling
parent cf9693169c
commit 0703ba118b
Notes: github-actions[bot] 2024-10-20 06:50:56 +00:00
2 changed files with 10 additions and 0 deletions

View file

@ -27,6 +27,14 @@ Optional<u32> Utf32CodePointIterator::peek(size_t offset) const
return *new_iterator; return *new_iterator;
} }
bool Utf32View::operator==(Utf32View const& other) const
{
ReadonlySpan<u32> code_points { m_code_points, m_length };
ReadonlySpan<u32> other_code_points { other.m_code_points, other.m_length };
return code_points == other_code_points;
}
ErrorOr<void> Formatter<Utf32View>::format(FormatBuilder& builder, Utf32View const& string) ErrorOr<void> Formatter<Utf32View>::format(FormatBuilder& builder, Utf32View const& string)
{ {
return builder.builder().try_append(string); return builder.builder().try_append(string);

View file

@ -119,6 +119,8 @@ public:
return substring_view(offset, length() - offset); return substring_view(offset, length() - offset);
} }
bool operator==(Utf32View const& other) const;
private: private:
u32 const* begin_ptr() const u32 const* begin_ptr() const
{ {