Using the following simple test code I am not seeing any problems. Is this the type of code that you would expect to show problems?
In the header file I have:
#include <map>
#include <list>
struct testDataStructForTemplates
{
int nDataOne;
int nDataTwo;
};
class usingMapListTemplates
{
private:
std::map<int, testDataStructForTemplates> mapNumberData;
std::map<std::string, testDataStructForTemplates> mapNameData;
std::list<long> listNumbers;
std::list<std::string> listNames;
std::list<testDataStructForTemplates> listData;
std::list<std::map<int, testDataStructForTemplates> > listMapNumberData;
public:
void initialiseData();
void scanData();
};
and in the cpp file I have:
void usingMapListTemplates::initialiseData()
{
mapNumberData[1].nDataOne = 11;
mapNumberData[1].nDataTwo = 12;
mapNumberData[2].nDataOne = 13;
mapNumberData[2].nDataTwo = 14;
mapNumberData[3].nDataOne = 15;
mapNumberData[3].nDataTwo = 16;
mapNameData["fred"].nDataOne = 3;
mapNameData["jane"].nDataTwo = mapNameData["fred"].nDataOne + 3;
listNumbers.push_back(23);
listNumbers.push_back(47);
listNumbers.push_back(81);
listNames.push_back(std::string("barbara"));
listNames.push_back(std::string("lucy"));
testDataStructForTemplates dataInstance1, dataInstance2;
dataInstance1.nDataOne = 1;
dataInstance1.nDataTwo = 1;
dataInstance2.nDataOne = 2;
dataInstance2.nDataTwo = 2;
listData.push_front(dataInstance1);
listData.push_front(dataInstance2);
listMapNumberData.push_back(mapNumberData);
}
void usingMapListTemplates::scanData()
{
int nTotal = 0;
std::map<int, testDataStructForTemplates>::iterator it1;
for(it1 = mapNumberData.begin(); it1 != mapNumberData.end(); ++it1) { }
std::map<std::string, testDataStructForTemplates>::iterator it2;
for(it2 = mapNameData.begin(); it2 != mapNameData.end(); ++it2) { }
std::list<std::map<int, testDataStructForTemplates> >::const_iterator it3;
for(it3 = listMapNumberData.begin(); it3 != listMapNumberData.end(); ++it3) { }
}