By nicely I mean something that is more readable and less spammy
I guess it's arguable whether this is an improvement or not (and this very statement begs the questions whether the OP can only be answered in an opinion based manner?), but as it makes use of new C++20 feature it may prove useful for readers of this question nonetheless.
You could combine structured bindings with range-based for loop initialization statements separate the initialization of the matrix object with that of the structured bindings loop over its elements; e.g.:
for (const int matrix[3][3] =
{{1, 2, 3}, {47, 48, 49}, {100, 200, 300}};
const auto [x, y, z] : matrix)
{
// ...
}
for (const auto matrix =
{std::array{1, 2, 3}, {47, 48, 49}, {100, 200, 300}};
const auto [x, y, z] : matrix)
{
// ...
}
for (typedef std::array<int, 3> Row;
const auto [x, y, z] : {Row{1, 2, 3}, {47, 48, 49}, {100, 200, 300}})
{
// ...
}
where the final example makes use of the fact that typedef
declarations are init-statements (where alias-declarations are not).