I need to convert multimap into a void buffer, and pass it into a function where the multimap should be reconstructed.
I know there is easy way to simply pass the multimap, but I need to do via the void pointer so please look at my logic below:
using namespace std;
void reconstruct_mm(void *ptr, size_t len) {
multimap<int, int> *mm = ptr;
mm = (multimap<<int, int>*>malloc(len));
*** print the following 10, 20, 30...
}
int main (void) {
void *buffer;
size_t buffer_len = 0;
multimap <int, int> m;
// fill in multimap with values
m.insert(pair <int, int> (1, 10);
m.insert(pair <int, int> (2, 20);
m.insert(pair <int, int> (3, 30);
// from this point I need your help, I only wrote logic what I expect from the program.
buffer = &mm;
buffer_len = sizeof(mm);
reconstruct_mm(buffer, buffer_len);
}
Thank you in advance!