From 6452bd4350ba333b84edae30f557e6edb0c8e500 Mon Sep 17 00:00:00 2001 From: JustinAJ Date: Mon, 2 Jun 2014 20:23:48 -0400 Subject: [PATCH] Changed get() to return a constant element. --- Jupiter/Readable_String.h | 4 ++-- Jupiter/String_Type.h | 3 ++- Jupiter/String_Type_Imp.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Jupiter/Readable_String.h b/Jupiter/Readable_String.h index 5457c88..d3cce64 100644 --- a/Jupiter/Readable_String.h +++ b/Jupiter/Readable_String.h @@ -46,7 +46,7 @@ namespace Jupiter * @param index Index of the element to return. * @return The element located at the specified index. */ - virtual T &get(size_t index) const = 0; + virtual const T &get(size_t index) const = 0; /** * @brief Returns the number of elements in the String. @@ -201,7 +201,7 @@ namespace Jupiter template class R> static R gotoWord(const T *in, size_t pos, const T *whitespace); /** Access operator */ - inline T &operator[](size_t index) const { return this->get(index); }; + inline const T &operator[](size_t index) const { return this->get(index); }; /** Comparative operators */ inline bool operator==(const Readable_String &right)const{ return this->equals(right); } diff --git a/Jupiter/String_Type.h b/Jupiter/String_Type.h index 23db529..5094ea3 100644 --- a/Jupiter/String_Type.h +++ b/Jupiter/String_Type.h @@ -46,7 +46,8 @@ namespace Jupiter * @param index Index of the element to return. * @return The element located at the specified index. */ - T &get(size_t index) const; + const T &get(size_t index) const; + //T &get(size_t index) const; /** * @brief Returns the number of elements in the String. diff --git a/Jupiter/String_Type_Imp.h b/Jupiter/String_Type_Imp.h index 4c33ac3..407614b 100644 --- a/Jupiter/String_Type_Imp.h +++ b/Jupiter/String_Type_Imp.h @@ -40,7 +40,7 @@ template Jupiter::String_Type::String_Type(Jupiter::String_Type T &Jupiter::String_Type::get(size_t index) const +template const T &Jupiter::String_Type::get(size_t index) const { return Jupiter::String_Type::str[index]; }