From f8462d9953053fe2c5e717d6e7160e1abce29b80 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 6 Feb 2004 22:50:37 +0000 Subject: [PATCH] g++ 3.4 fixes --- stepmania/src/StdString.h | 83 +++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/stepmania/src/StdString.h b/stepmania/src/StdString.h index 65aca80c34..d5d05f1644 100644 --- a/stepmania/src/StdString.h +++ b/stepmania/src/StdString.h @@ -556,6 +556,47 @@ inline void ssadd(std::string& sDst, PCSTR pA) // ============================================================================= //#define CStdStr _SS // avoid compiler warning 4786 +template +class CStdStr; + +template +inline +CStdStr operator+(const CStdStr& str1, const CStdStr& str2) +{ + CStdStr strRet(str1); + strRet.append(str2); + return strRet; +} + +template +inline +CStdStr operator+(const CStdStr& str, CT t) +{ + // this particular overload is needed for disabling reference counting + // though it's only an issue from line 1 to line 2 + + CStdStr strRet(str); // 1 + strRet.append(1, t); // 2 + return strRet; +} + +template +inline +CStdStr operator+(const CStdStr& str, PCSTR pA) +{ + return CStdStr(str) + CStdStr(pA); +} + +template +inline +CStdStr operator+(PCSTR pA, const CStdStr& str) +{ + CStdStr strRet(pA); + strRet.append(str); + return strRet; +} + + template class CStdStr : public std::basic_string @@ -800,7 +841,7 @@ public: // But practically speaking, this works faster - if ( !empty() ) + if ( !this->empty() ) ssupr(GetBuf(), this->size()); return *this; @@ -819,7 +860,7 @@ public: // But practically speaking, this works faster - if ( !empty() ) + if ( !this->empty() ) sslwr(GetBuf(), this->size()); return *this; @@ -834,7 +875,7 @@ public: // ------------------------------------------------------------------------- CT* GetBuf(int nMinLen=-1) { - if ( static_cast(size()) < nMinLen ) + if ( static_cast(this->size()) < nMinLen ) this->resize(static_cast(nMinLen)); return this->empty() ? const_cast(this->data()) : &(this->at(0)); @@ -1186,42 +1227,6 @@ public: // ----------------------------------------------------------------------------- // CStdStr friend addition functions defined as inline // ----------------------------------------------------------------------------- -template -inline -CStdStr operator+(const CStdStr& str1, const CStdStr& str2) -{ - CStdStr strRet(str1); - strRet.append(str2); - return strRet; -} - -template -inline -CStdStr operator+(const CStdStr& str, CT t) -{ - // this particular overload is needed for disabling reference counting - // though it's only an issue from line 1 to line 2 - - CStdStr strRet(str); // 1 - strRet.append(1, t); // 2 - return strRet; -} - -template -inline -CStdStr operator+(const CStdStr& str, PCSTR pA) -{ - return CStdStr(str) + CStdStr(pA); -} - -template -inline -CStdStr operator+(PCSTR pA, const CStdStr& str) -{ - CStdStr strRet(pA); - strRet.append(str); - return strRet; -}