diff --git a/src/fstring.cpp b/src/fstring.cpp index 6fefd216..bfff3f9d 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -443,24 +443,6 @@ const FString& FString::operator >> (float& num) return *this; } -//---------------------------------------------------------------------- -wchar_t& FString::operator [] (std::size_t pos) -{ - if ( pos >= length ) - throw std::out_of_range(""); // Invalid index position - - return string[pos]; -} - -//---------------------------------------------------------------------- -const wchar_t& FString::operator [] (std::size_t pos) const -{ - if ( pos >= length ) - throw std::out_of_range(""); // Invalid index position - - return string[pos]; -} - //---------------------------------------------------------------------- const FString& FString::operator () () { diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 10738cea..73ac4866 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -137,8 +137,6 @@ class FString wchar_t& operator [] (IndexT); template const wchar_t& operator [] (IndexT) const; - wchar_t& operator [] (std::size_t); - const wchar_t& operator [] (std::size_t) const; const FString& operator () (); bool operator < (const FString&) const; @@ -292,12 +290,22 @@ inline const char* FString::getClassName() //---------------------------------------------------------------------- template inline wchar_t& FString::operator [] (IndexT pos) -{ return string[std::size_t(pos)]; } +{ + if ( pos < 0 || pos >= IndexT(length) ) + throw std::out_of_range(""); // Invalid index position + + return string[std::size_t(pos)]; +} //---------------------------------------------------------------------- template inline const wchar_t& FString::operator [] (IndexT pos) const -{ return string[std::size_t(pos)]; } +{ + if ( pos < 0 || pos >= IndexT(length) ) + throw std::out_of_range(""); // Invalid index position + + return string[std::size_t(pos)]; +} //---------------------------------------------------------------------- template