BAN: Vector now has Back() and Front() helpers

This commit is contained in:
Bananymous 2022-12-13 15:08:12 +02:00
parent b491007eac
commit b42469efd7
1 changed files with 32 additions and 0 deletions

View File

@ -30,6 +30,11 @@ namespace BAN
const T& operator[](size_type) const;
T& operator[](size_type);
const T& Back() const;
T& Back();
const T& Front() const;
T& Front();
ErrorOr<void> Resize(size_type);
ErrorOr<void> Reserve(size_type);
@ -105,6 +110,33 @@ namespace BAN
return m_data[index];
}
template<typename T>
const T& Vector<T>::Back() const
{
assert(m_size > 0);
return m_data[m_size - 1];
}
template<typename T>
T& Vector<T>::Back()
{
assert(m_size > 0);
return m_data[m_size - 1];
}
template<typename T>
const T& Vector<T>::Front() const
{
assert(m_size > 0);
return m_data[0];
}
template<typename T>
T& Vector<T>::Front()
{
assert(m_size > 0);
return m_data[0];
}
template<typename T>
ErrorOr<void> Vector<T>::Resize(size_type size)
{