The following code works as expected to initialize a vector of structs:
#include <array>
struct node
{
std::string name;
std::string value;
};
const std::vector<node> reqFields ({
{ "query", tmpEmail },
{ "firstname", firstName },
{ "lastname", lastName }
});
I want to optimize my code a bit to use a C++ 11 array instead, given that my data is static. However, the following won't compile:
const std::array<node, 3>({
{ "query", tmpEmail },
{ "firstname", firstName },
{ "lastname", lastName }
});
What is the right syntax to initialize the array? or maybe this is something that Visual Studio 15 has trouble with?