From f9c3ae709070977f83f1b4d742e3234644274094 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 29 Mar 2023 14:10:29 +0300 Subject: [PATCH] BAN: String add front() and back() helpers --- BAN/include/BAN/String.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BAN/include/BAN/String.h b/BAN/include/BAN/String.h index 843f9a43..0853587b 100644 --- a/BAN/include/BAN/String.h +++ b/BAN/include/BAN/String.h @@ -46,6 +46,12 @@ namespace BAN const_iterator end() const { return const_iterator(m_data + m_size); } iterator end() { return iterator(m_data + m_size); } + char front() const { ASSERT(!empty()); return m_data[0]; } + char& front() { ASSERT(!empty()); return m_data[0]; } + + char back() const { ASSERT(!empty()); return m_data[m_size - 1]; } + char& back() { ASSERT(!empty()); return m_data[m_size - 1]; } + char operator[](size_type) const; char& operator[](size_type);