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?
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With