From 5c20beaf1cd118d43bc58c0bb5ade93b7abf3244 Mon Sep 17 00:00:00 2001 From: Marco Leogrande Date: Fri, 2 Feb 2024 21:32:59 -0800 Subject: [PATCH] Add more debug info --- create_random.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/create_random.cc b/create_random.cc index 9cb21ab..c87a0be 100644 --- a/create_random.cc +++ b/create_random.cc @@ -106,8 +106,18 @@ std::optional create_random_board(const uint16_t board_size, std::mt19937 // restore the leftover trackers. const int current_value = b.at(state.row, state.column); if (current_value != 0) { - rows[state.row].insert(current_value); - columns[state.column].insert(current_value); + auto [r_i, r_inserted] = rows[state.row].insert(current_value); + if (!r_inserted) { + std::cerr << "FATAL: failed to insert value " << current_value << " into row " + << state.row << ". This should never happen." << std::endl; + return std::nullopt; + } + auto [c_i, c_inserted] = columns[state.column].insert(current_value); + if (!c_inserted) { + std::cerr << "FATAL: failed to insert value " << current_value << " into column " + << state.column << ". This should never happen." << std::endl; + return std::nullopt; + } } // Take and use the next legal value for the current cell.