From 4fac4627cdf0494a7d6a4a2df26e7ac61ae1ae41 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 15 Oct 2018 01:51:09 +0200 Subject: [PATCH] FString fix for 32-bit architectures --- src/fstring.cpp | 18 ------------------ src/include/final/fstring.h | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 22 deletions(-) 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