andre de boer andre de boer - 1 year ago 178
C++ Question

C++ how to insert in multimap?

I want to set up a multimap in C++:

multimap<pair<string, string>, vector<double> > mmList;

But how to insert data:

mmList.insert(pair<string, string>, vector<double>("a", "b", test));

Answer Source

You can construct pairs using std::make_pair(a, b). Generally you can insert pairs into maps/multimaps. In your case you have to construct a pair consisting of the string pair and the vector:

    std::multimap<std::pair<std::string, std::string>, std::vector<double> > mmList;

    std::vector<double> vec;
    mmList.insert(std::make_pair(std::make_pair("a","b"), vec));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download