Gregory J.

I've a problem with this code:

#include <iostream>

#include <vector>

#include <map>

#include <string>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

vector<string> vs;

vs.push_back("Hello");

vector<vector<string> > vvs;

vvs.push_back(vs);

map<string, vector<vector<string> > > m;

m["key"] = vvs; // error

return 0;

}

The compiler doesn't show errors, but when I execute it in debugging I see that m contains an error message.

Does somebody know where the problem

Thank you



Re: Visual C++ General Error with map<string, vector<vector<string> > >

Viorel.

Probably the Visual Studio Debugger is not yet able to display such complex data type. But the map contains a good value. In order to check, add this line:

const vector< vector< string > > & vvs1 = m["key"];

The value of vvs1 will be displayed correctly.

I think this debugger problem can be reported to Microsoft at http://connect.microsoft.com/VisualStudio/feedback.





Re: Visual C++ General Error with map<string, vector<vector<string> > >

Sarath.

AFAIK, the code has no problem. The code has been successfully compiled and executed in the Dev C++. Probably the bug of Visual C++.

Sample code:

int main(int argc, char* argv[])
{
vector<string> vs;
vs.push_back("Hello");
vector<vector<string> > vvs;
vvs.push_back(vs);map<string, vector<vector<string> > > m;
m["key"] = vvs;
cout<<m["key"].at(0).at(0);
system("PAUSE");
return 0;
}






Re: Visual C++ General Error with map<string, vector<vector<string> > >

Gregory J.

Thank you, I have verified that it works