Move OwnedStringView::operator[] out of line

This commit is contained in:
apio 2022-12-16 20:48:58 +01:00
parent 59765aa334
commit da39ba33a9
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 7 additions and 5 deletions

View File

@ -22,11 +22,7 @@ class OwnedStringView
return m_length; return m_length;
} }
const char& operator[](usize index) const const char& operator[](usize) const;
{
expect(index < m_length, "OwnedStringView: index out of range");
return m_string[index];
}
private: private:
char* m_string{nullptr}; char* m_string{nullptr};

View File

@ -33,4 +33,10 @@ Result<OwnedStringView> OwnedStringView::clone() const
if (!c_str) return err(ENOMEM); if (!c_str) return err(ENOMEM);
return OwnedStringView{c_str}; return OwnedStringView{c_str};
}
const char& OwnedStringView::operator[](usize index) const
{
expect(index < m_length, "index out of range");
return m_string[index];
} }