diff --git a/src/util/ConfigManager/ConfigOption.cpp b/src/util/ConfigManager/ConfigOption.cpp index 98ce5be7b8..376728efcc 100644 --- a/src/util/ConfigManager/ConfigOption.cpp +++ b/src/util/ConfigManager/ConfigOption.cpp @@ -118,12 +118,8 @@ void ConfigOption::setValueWithJson(const nlohmann::json& json) { data_)) { // Does the json represent one of the types in our `AvailableTypes`? If yes, // we can create a better exception message. - ad_utility::ConstexprForLoop( - std::make_index_sequence>{}, - [&isValueTypeSubType, &json, - this ]>() { + forEachTypeInTemplateType( + [&isValueTypeSubType, &json, this]() { if (isValueTypeSubType.template operator()( json, isValueTypeSubType)) { throw ConfigOptionSetWrongJsonTypeException( diff --git a/src/util/ConstexprUtils.h b/src/util/ConstexprUtils.h index 66cb9b63e9..9cbc02c262 100644 --- a/src/util/ConstexprUtils.h +++ b/src/util/ConstexprUtils.h @@ -4,10 +4,12 @@ #pragma once +#include #include #include "util/Exception.h" #include "util/Forward.h" +#include "util/TypeTraits.h" // Various helper functions for compile-time programming. @@ -199,4 +201,40 @@ auto cartesianPowerAsIntegerArray() { return toIntegerSequence()>(); } +/* +@brief Call the given lambda function with each of the given types `Ts` as +explicit template parameter, keeping the same order. +*/ +template +constexpr void forEachTypeInParameterPack(const auto& lambda) { + (lambda.template operator()(), ...); +} + +/* +Implementation for `forEachTypeInTemplateType`. + +In order to go through the types inside a templated type, we need to use +template type specialization. +*/ +namespace detail { +template +struct forEachTypeInTemplateTypeImpl; + +template