Skip to content

Commit

Permalink
Add static_assert for algorithm tuple size
Browse files Browse the repository at this point in the history
Sanity check so that compilation fails if an algorithm has not been
added to both the type tuple and the enum. This situation caused
confusion for those new to the project when the `Desbordante_run`
executable failed with an obscure error if they forgot to add their
new algorithm to either of them.
  • Loading branch information
BUYT-1 authored and polyntsov committed Jul 29, 2023
1 parent 4e547aa commit 25fef5c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/algorithms/algorithm_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ BETTER_ENUM(AlgorithmType, char,
)
// clang-format on

static_assert(std::tuple_size_v<AlgorithmTypes> == AlgorithmType::_size(),
"The AlgorithmTypes tuple and the AlgorithmType enum sizes must be the same. Did you "
"forget to add your new algorithm to either of those?");

} // namespace algos

0 comments on commit 25fef5c

Please sign in to comment.