c++ statically initialize map<float, float[3]>
arrays, c++, dictionary, list, static
Solution
You should use `array<float, 3>` instead of "plain" arrray:
#include <map>
#include <array>
#include <iostream>
int main()
{
std::map<float, std::array<float, 3>> myMap
{
{415, std::array<float, 3>{1, 52356, 2}},
{256, std::array<float, 3>{356, 23, 6}}
//...etc
};
/* OR
std::map<float, std::array<float, 3>> myMap
{
{415, {{1, 52356, 2}}},
{256, {{356, 23, 6}}}
//...etc
};
*/
std::cout << myMap[415][0] << " " << myMap[256][1] << " " << std::endl;
return 0;
}
Problem
So I have a map myMap that I'm trying to statically initialize (has to be done this way). I'm doing the following: ``` myMap = { {415, {1, 52356, 2}}, {256, {356, 23, 6}}, //...etc }; ``` However I'm getting the following error: "Array initializer must be an initializer list." What is wrong with the syntax I have above?