Severity Code Description Project File Line Suppression State
Error C2678 binary '[': no operator found which takes a left-hand operand of type 'const TMap<FString,FString,FDefaultSetAllocator,TDefaultMapHashableKeyFuncs<KeyType,ValueType,false>>' (or there is no acceptable conversion)
string์ด๋ array ๋ฐ์๋ชป๋ฐ๋ ํจ์์ mapํ์ ์ฐ๋ ค๊ณ ๋ง๋ค๊ณ ์๋๋ฐ
์๋ณธํจ์
template<class ElementType>
void WriteValue(const FString& Identifier, const TArray<ElementType>& Array)
{
WriteArrayStart(Identifier);
for (int Idx = 0; Idx < Array.Num(); Idx++)
{
WriteValue(Array[Idx]);
}
WriteArrayEnd();
}
//////////////
template<class ElementType>
void WriteValue(const FString& Identifier, const TMap<ElementType, ElementType>& Map)
{
WriteArrayStart(Identifier);
for (int Idx = 0; Idx < Map.Num(); Idx++)
{
WriteValue(Map[Idx]);
}
WriteArrayEnd();
}
์ฌ๊ธฐ์ ๋ญ๋ ๊ณ ์ณ์ผ๋ ๊น??
map ์ดํด๊ฐ๋ฎ์์ ์๋ชจ๋ฅด๊ฒ๋ค
์๋๋ฉด TArray ์ TMap์ง์ด๋ฃ๋๋ฒ ์๋ ค์ค
TMap์ ๋ชป๋ฃ์์ง๋ง ๋ค๋ฅธ๋ฐฉ์์ผ๋ก ํด๊ฒฐํจ
ElementType, ElementType ํค๋ฐ๋ฅ ์ผ๋ถ๋ฌ ๋๊ฐ์ด ํ๊ฑฐ์?
์ ๊ฑฐ๋ ๋์ค์ ๋ค๋ฅธํ์ผ๋ก๋ฐ๊ฟ์์๋ ํ ํ๋ฆฟ์ผ๊ป ์์ array๋ ๋์ค์ ์ธ๋๋ TArray ์ด๋ฐ์์ผ๋ก๋๊ฑฐ ๋ค์ด๊ฐ
TArray(FString)
๊บฝ์๊ฐ ๋๊ธ์์ ์์์จ์ง๋ ธ
๊ทธ๊ฒ ์๋๋ผ TMap์ด๋ ๋์ ๋๋ฆฌ ๊ฐ์ ์ ๋ค์, ์๋ฃํ ๋๊ฐ๋ฅผ ํ ํ๋ฆฟ์ผ๋ก ๋ฐ์์, ํค์ ์๋ฃํ๊ณผ ๋ฐ๋ฅ์ ์๋ฃํ. ๊ทธ๋์ ๋์ ๋๊ฐ์๊ฒ์ผ๋ก ํ๊ฐ ๋์ ์๋์๋๊ณ ๋ฌป๋๊ฑฐ๊ณ ์๋๋ผ๋ฉด ์๋ง ์ด์ชฝ๋ถ๋ถ์์ ๋๊ฐ ์ดํด๋ฅผ ๋ชปํด์ ์ค์๋ฅผ ํ๊ฑฐ ์๋๊น ์ถ์๊ฑฐ์ง
์ด์ฐจํผ ๊ฐ์๊ฑฐ์ธ๊บผ๋ผ ์๊ด์์ด์ ๊ทธ๋ ๊ฒํ์ - dc App
๋ฐ์ ํฌ๋ฌธ์์๊ฐ ํ๋ฆฐ๊ฑฐ๋ผ ๊ทธ๊ฑฐ๊ณ ์น๊ณ ํด๊ฒฐํ์ - dc App