Add another pair of braces.
std::array<std::pair<int, int>, 2> ids = { { { 0, 1 }, { 1, 2 } } };
std::array<T, N>
is an aggregate class containing a member of type T[N]
. Usually, you can initialise that the same way you would a plain T[N]
array, but when you're dealing with a non-aggregate element type, you may need to be more explicit.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…