view raw
andre de boer andre de boer - 6 months ago 49
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));


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));