File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
Sofa/framework/Helper/src/sofa/helper Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change 2727#include < sofa/helper/logging/Messaging.h>
2828#include < sofa/type/fixed_array.h>
2929#include < map>
30+ #include < ranges>
3031
3132
3233namespace sofa ::helper
@@ -240,23 +241,15 @@ class SelectableItem : public BaseSelectableItem
240241
241242 static constexpr id_type findId (const std::string_view key)
242243 {
243- return findId_impl (key, std::make_index_sequence<numberOfItems ()>{});
244- }
245-
246- template <id_type... Is>
247- static constexpr id_type findId_impl (const std::string_view key, std::index_sequence<Is...>)
248- {
249- constexpr id_type indices[] = { Is... };
250- id_type result = static_cast <id_type>(-1 );
251- for (id_type i : indices)
244+ // use std::ranges::enumerate in C++23
245+ for (id_type i = 0 ; i < numberOfItems (); ++i)
252246 {
253- if (Derived::s_items[i].key == key)
247+ if (key == Derived::s_items[i].key )
254248 {
255- result = i;
256- break ;
249+ return i;
257250 }
258251 }
259- return result ;
252+ return static_cast <id_type>(- 1 ) ;
260253 }
261254
262255 template <typename , typename = std::void_t <>>
You can’t perform that action at this time.
0 commit comments