1

I don't understand why this code works:

std::map<int,char> map2;
map2.insert (std::pair<int,char>(3,'a'));

But this doesn't:

std::map<int,double[2]> map1;
map1.insert (std::pair<int,double[2]>(100,{0,0}));
Jose Soto
  • 25
  • 3
  • 1
    Do you get the same problem if you just try to create a `std::pair` _without_ inserting it into a map? In other words, is the problem really the insertion, or the construction? – Tim Randall Sep 05 '18 at 19:39

1 Answers1

0

The answer you are loooking for is here: Using array as map value: can't see the error

Where the last answer explains it as arrays are not assignable or copy constructible, therefore cannot be mapped to.

As an alternative, you can use pointer arrays or vectors.

dgkr
  • 345
  • 2
  • 8