From ec8034ddebf465da65dcedef4db2c2bf6f982f9c Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 30 Apr 2023 01:08:22 +0200 Subject: [PATCH] STYLE: Simplify ForEachSupportedImageType, using a C++17 fold expression --- Core/Main/elxForEachSupportedImageType.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Core/Main/elxForEachSupportedImageType.h b/Core/Main/elxForEachSupportedImageType.h index a94c60905..60c4c8b14 100644 --- a/Core/Main/elxForEachSupportedImageType.h +++ b/Core/Main/elxForEachSupportedImageType.h @@ -31,19 +31,10 @@ template void ForEachSupportedImageType(const TFunction & func, const std::index_sequence &) { - struct Empty - {}; - - const auto supportImageTypeWithIndex = [&func](const auto index) { - // Use `index + 1` instead of `index`, because the indices from SupportedImageTypes start with 1, while the sequence - // returned by `std::make_index_sequence()` starts with zero. - func(elx::ElastixTypedef{}); - return Empty{}; - }; - - // Expand the "variadic template" index sequence by the initialization of a dummy array. - const Empty dummyArray[] = { supportImageTypeWithIndex(std::integral_constant{})... }; - (void)dummyArray; + // Expand the "variadic template" index sequence by a fold expression. Use `index + 1` instead of `index`, because the + // indices from SupportedImageTypes start with 1, while the sequence returned by `std::make_index_sequence()` starts + // with zero. + (func(elx::ElastixTypedef{}), ...); } @@ -51,7 +42,6 @@ ForEachSupportedImageType(const TFunction & func, const std::index_sequence void ForEachSupportedImageType(const TFunction & func) - { ForEachSupportedImageType(func, std::make_index_sequence()); }