Is it possible to use a vector in a map in STL?

Is it possible to declare a card like

map<string, vector<string>> mymap;

I thought it was applicable.

However, this does not show.

I tried

map<string, vector<string>*> mymap;

and then ok

What is the rule of this?

+3
source share
2 answers

You need extra space:

map<string, vector<string> > mymap;
                          ^ see the extra space

Without extra space, it is >>parsed as a right shift operator.

The rules have been changed in C ++ 0x, which makes extra space unnecessary. Some compilers (for example, Visual C ++ 2008 and higher) no longer require additional space.

+17
source

You can, as James said. Stupid C ++ parsing :)

map<string, vector<string> > multimap<string, string>. A multimap . , .

+9

Source: https://habr.com/ru/post/1748761/


All Articles