lundi 28 août 2017

C++ Cannot convert from Initializer List to std::pair

I have a function called TestFunction which I've simplified down for this question... but in essence, I'm getting an error which says, " cannot convert from 'initializer list' to std::pair". Here's my simplified function:

#include <iostream>
#include <map>

void MyClass::TestFunction(cli::array<int>^ ids){

    std::multimap<int, int> mymap;
    int count = ids->Length;

    for (int i = 0; i < count; ++i) {
        //fill in the multimap with the appropriate data key/values
        mymap.insert(std::pair<int, int>((int)ids[i], (int)i));
    }
}

As you can see, it's a really basic function (when simplified), but I get an error when I try to insert the data into the multimap. Does anyone know why?

Aucun commentaire:

Enregistrer un commentaire