From 25fef5cd6cac4e6df0573835a0159545b7bfba80 Mon Sep 17 00:00:00 2001 From: Alexey Shlyonskikh Date: Thu, 6 Jul 2023 21:31:45 +0700 Subject: [PATCH] Add static_assert for algorithm tuple size 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. --- src/algorithms/algorithm_types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/algorithms/algorithm_types.h b/src/algorithms/algorithm_types.h index b1d36d256..fe0a2f430 100644 --- a/src/algorithms/algorithm_types.h +++ b/src/algorithms/algorithm_types.h @@ -54,4 +54,8 @@ BETTER_ENUM(AlgorithmType, char, ) // clang-format on +static_assert(std::tuple_size_v == 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