diff --git a/samples/matter/common/src/util/finite_map.h b/samples/matter/common/src/util/finite_map.h index 4a024a31e404..7998e6108f45 100644 --- a/samples/matter/common/src/util/finite_map.h +++ b/samples/matter/common/src/util/finite_map.h @@ -36,13 +36,24 @@ namespace Nrf key. * T2 must have move semantics and bool()/==operators implemented */ + +template struct KeyTypeHelper { + using type = T; +}; + +template struct KeyTypeHelper { + using type = typename std::underlying_type::type; +}; + template struct FiniteMap { static_assert(std::is_trivial_v); - static constexpr T1 kInvalidKey{ std::numeric_limits::max() }; - static constexpr std::size_t kNoSlotsFound{ N + 1 }; + using KeyType = typename KeyTypeHelper>::type; using ElementCounterType = uint16_t; + static constexpr T1 kInvalidKey{ static_cast(std::numeric_limits::max()) }; + static constexpr std::size_t kNoSlotsFound{ N + 1 }; + struct Item { /* Initialize with invalid key (0 is a valid key) */ T1 key{ kInvalidKey };