From 13f01597050191b604e7cbbd33c8cdcdc503169b Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 2 Nov 2015 22:17:53 +0000 Subject: [PATCH] Fix ambiguous overload resolution One operator+ for CBotString is enough --- src/CBot/CBotDll.h | 1 - src/CBot/CBotFunction.cpp | 2 +- src/CBot/CBotString.cpp | 7 ------- src/CBot/CBotVar.cpp | 2 +- test/unit/CBot/CBotString_test.cpp | 3 --- 5 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/CBot/CBotDll.h b/src/CBot/CBotDll.h index c05e1a50..47dbb480 100644 --- a/src/CBot/CBotDll.h +++ b/src/CBot/CBotDll.h @@ -397,7 +397,6 @@ public: const CBotString& operator=(const CBotString& stringSrc); const CBotString& operator=(const char ch); const CBotString& operator=(const char* pString); - friend CBotString operator+(const CBotString& string, const char* lpsz); CBotString operator+(const CBotString& str); const CBotString& operator+=(const char ch); diff --git a/src/CBot/CBotFunction.cpp b/src/CBot/CBotFunction.cpp index 4bc4303c..4ef40216 100644 --- a/src/CBot/CBotFunction.cpp +++ b/src/CBot/CBotFunction.cpp @@ -216,7 +216,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct if ( IsOfType(p, ID_NOT) ) { - CBotToken d("~" + p->GetString()); + CBotToken d(CBotString("~") + p->GetString()); func->m_token = d; } diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp index 5f7792c1..52e63a34 100644 --- a/src/CBot/CBotString.cpp +++ b/src/CBot/CBotString.cpp @@ -337,13 +337,6 @@ const CBotString& CBotString::operator=(const CBotString& stringSrc) return *this; } -CBotString operator+(const CBotString& string, const char * lpsz) -{ - CBotString s(string); - s += lpsz; - return s; -} - CBotString CBotString::operator+(const CBotString& stringSrc) { CBotString s(*this); diff --git a/src/CBot/CBotVar.cpp b/src/CBot/CBotVar.cpp index da5119f8..2898a92a 100644 --- a/src/CBot/CBotVar.cpp +++ b/src/CBot/CBotVar.cpp @@ -1703,7 +1703,7 @@ void CBotVarClass::DecrementUse() pThis->SetPointer(this); CBotVar* pResult = nullptr; - CBotString nom = "~" + m_pClass->GetName(); + CBotString nom = CBotString("~") + m_pClass->GetName(); long ident = 0; while ( pile->IsOk() && !m_pClass->ExecuteMethode(ident, nom, pThis, ppVars, pResult, pile, nullptr)) ; // waits for the end diff --git a/test/unit/CBot/CBotString_test.cpp b/test/unit/CBot/CBotString_test.cpp index ebec2024..97576a99 100644 --- a/test/unit/CBot/CBotString_test.cpp +++ b/test/unit/CBot/CBotString_test.cpp @@ -277,9 +277,6 @@ TEST(CBotString_Test, operatorAdd) botStr1 = botStr1 + botStr3; EXPECT_STREQ(botStr1.CStr(), botStr4.CStr()); - botStr1 = "C" + botStr3; - EXPECT_STREQ(botStr1.CStr(), botStr4.CStr()); - botStr1.Empty(); botStr1 = botStr2 + cStr1; EXPECT_STREQ(botStr1.CStr(), botStr4.CStr());