diff --git a/Sofa/framework/Helper/src/sofa/helper/SelectableItem.h b/Sofa/framework/Helper/src/sofa/helper/SelectableItem.h index 9fd1eba9891..06a86c4cc9b 100644 --- a/Sofa/framework/Helper/src/sofa/helper/SelectableItem.h +++ b/Sofa/framework/Helper/src/sofa/helper/SelectableItem.h @@ -240,27 +240,20 @@ class SelectableItem : public BaseSelectableItem static constexpr id_type findId(const std::string_view key) { - return findId_impl(key, std::make_index_sequence{}); - } - - template - static constexpr id_type findId_impl(const std::string_view key, std::index_sequence) - { - id_type result = static_cast(-1); - ((Derived::s_items[Is].key == key ? (result = Is, true) : false) || ...); - return result; + //use std::ranges::enumerate in C++23 + for (id_type i = 0; i < numberOfItems(); ++i) + { + if (key == Derived::s_items[i].key) + { + return i; + } + } + return static_cast(-1); } - template > - struct has_deprecation_map : std::false_type {}; - - // Specialization when T has a static member s_foo - template - struct has_deprecation_map> : std::true_type {}; - void keyError(const std::string_view key) { - if constexpr (has_deprecation_map::value) + if constexpr (requires {Derived::s_deprecationMap;}) { static_assert(std::is_same_v, std::map>); const auto it = Derived::s_deprecationMap.find(key);