See this example: https://godbolt.org/z/5PqYWP
How come this array of pairs can't be initialized in the same way as a vector of pairs?
#include <vector>
#include <array>
int main()
{
std::vector<std::pair<int,int>> v{{1,2},{3,4},{5,6}}; // succeeds
std::array <std::pair<int,int>, 3> a{{1,2},{3,4},{5,6}}; // fails to compile
}
struct
instead of astd::pair
. But the answer there is much the same as any here would be, IMHO. (Or maybe not - that one is about an assignment rather than a constructor?) – Nonaggressionstruct
instead of astd::pair
I would expect that the std::pair is actually a (template)struct
. ;-) – Lewes