14 {
15 std::array<std::array<ValueType, target_col_count>, target_row_count> result {};
16 const size_t colCountToCopy = std::min(source_col_count, target_col_count);
17 const size_t rowCountToCopy = std::min(source_row_count, target_row_count);
18 for (size_t row = 0; row < rowCountToCopy; ++row) {
19 for (size_t col = 0; col < colCountToCopy; ++col) {
20 result[row][col] = source[row][col];
21 }
22 for (size_t col = colCountToCopy; col < target_col_count; ++col) {
23 result[row][col] = defaultValue;
24 }
25 }
26 for (size_t row = rowCountToCopy; row < target_row_count; ++row) {
27 for (size_t col = 0; col < target_col_count; ++col) {
28 result[row][col] = defaultValue;
29 }
30 }
31 return result;
32}