1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
template <typename T1, typename T2>
void ShowMeMap(map<T1, T2>* myTempMap, string _text, bool bIsDigit)
{
int currentSize = (*myTempMap).size();
if (bIsDigit)
{
string temp = "AddedNewOne";
typedef pair<int, string> ins_pair;
(*myTempMap).insert(ins_pair(10,"NewValueInserted"));
}
else
{
//list<string> tempList ;
//tempList.push_back("Add_1");
//tempList.push_back("Add_2");
//tempList.push_back("Add_3");
//typedef pair<int, list<string>> pairTempMap;
//(*myTempMap).insert(pairTempMap(12,&tempList));
//(*myTempMap)[currentSize] = tempList;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
map<int,list<string>> myComplicatedMap ;
map<int,string> myMap ;
typedef pair<int, list<string>> pairTempMap;
myMap[0] = "Starts";
myMap[1] = "ToShow";
myMap[2] = "Values";
list<string> textList;
textList.push_back("One");
textList.push_back("Two");
textList.push_back("Three");
textList.push_back("Four");
myComplicatedMap.insert(pairTempMap(1,textList));
ShowMeMap<int,string>(&myMap, "Text_Test",true);
// compiler error
//ShowMeMap <int,list<string>>(&myComplicatedMap, "Text_Teste2",false);
return 0;
}
| |