From da39ba33a9c90a3fb35875b19e20b2afb9d47c20 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 16 Dec 2022 20:48:58 +0100 Subject: [PATCH] Move OwnedStringView::operator[] out of line --- luna/include/luna/OwnedStringView.h | 6 +----- luna/src/OwnedStringView.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/luna/include/luna/OwnedStringView.h b/luna/include/luna/OwnedStringView.h index b5ce7622..8a47b597 100644 --- a/luna/include/luna/OwnedStringView.h +++ b/luna/include/luna/OwnedStringView.h @@ -22,11 +22,7 @@ class OwnedStringView return m_length; } - const char& operator[](usize index) const - { - expect(index < m_length, "OwnedStringView: index out of range"); - return m_string[index]; - } + const char& operator[](usize) const; private: char* m_string{nullptr}; diff --git a/luna/src/OwnedStringView.cpp b/luna/src/OwnedStringView.cpp index 8ac2df4b..80e42fa7 100644 --- a/luna/src/OwnedStringView.cpp +++ b/luna/src/OwnedStringView.cpp @@ -33,4 +33,10 @@ Result OwnedStringView::clone() const if (!c_str) return err(ENOMEM); return OwnedStringView{c_str}; +} + +const char& OwnedStringView::operator[](usize index) const +{ + expect(index < m_length, "index out of range"); + return m_string[index]; } \ No newline at end of file