Is there a way to insert a C-style array into a std::unordered_map
as value?
For example, the followings all give compiler error
#include <unordered_map>
int main() {
std::unordered_map <int, int[2]> testMap;
int temp[2]{ 0,0 };
//testMap.insert({ 1, temp });
//testMap[1] = temp;
//testMap.insert({1,{0,0}});
//testMap[1]=int[2]{0,0};
}
Or is it only possible to use a map for std::unordered_map <int, int*>
?
I understand that std::array<int,2>
would work instead. But I am new to C++ and hoping to understand the behavior of C-style array better.
2