mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 23:56:06 +00:00
AK: Add last() utility function to Span
This commit is contained in:
parent
77add584fa
commit
0f2c1f804e
Notes:
sideshowbarker
2024-07-17 16:18:36 +09:00
Author: https://github.com/MacDue
Commit: 0f2c1f804e
Pull-request: https://github.com/SerenityOS/serenity/pull/13386
Reviewed-by: https://github.com/awesomekling
1 changed files with 10 additions and 0 deletions
10
AK/Span.h
10
AK/Span.h
|
@ -212,6 +212,16 @@ public:
|
||||||
return this->m_values[index];
|
return this->m_values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] ALWAYS_INLINE constexpr T const& last() const
|
||||||
|
{
|
||||||
|
return this->at(this->size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] ALWAYS_INLINE constexpr T& last()
|
||||||
|
{
|
||||||
|
return this->at(this->size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] ALWAYS_INLINE constexpr T const& operator[](size_t index) const
|
[[nodiscard]] ALWAYS_INLINE constexpr T const& operator[](size_t index) const
|
||||||
{
|
{
|
||||||
return at(index);
|
return at(index);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue