when i use C++ array like this:
array<int, 8> test = {
1,
2,
3,
4,
5,
6,
7,
8
};
It's easy to understand, but when i use C++ array like this:
array<pair<int, int>, 8> dirs = {
{-1, -1},
{-1, 0},
{-1, 1},
{0, -1},
{0, 1},
{1, -1},
{1, 0},
{1, 1},
};
The compiler will report an error:No viable conversion from 'int' to 'std::pair<int, int>' But it compiled successfully when I use two curly braces:
array<pair<int, int>, 8> dirs = {{
{-1, -1},
{-1, 0},
{-1, 1},
{0, -1},
{0, 1},
{1, -1},
{1, 0},
{1, 1},
}};
I don't understand why i need two curly braces