Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix condition for XBT_DECLARE_ENUM_CLASS
authorMaxwell Pirtle <maxwellpirtle@gmail.com>
Tue, 14 Feb 2023 08:06:24 +0000 (09:06 +0100)
committerMaxwell Pirtle <maxwellpirtle@gmail.com>
Tue, 14 Feb 2023 08:06:24 +0000 (09:06 +0100)
The condition for the `is_valid_##EnumType`
was updated. Previously, is was missing the edge
case where `raw_value >= 0`

include/xbt/utility.hpp

index 6a3b542..bb599d6 100644 (file)
@@ -27,7 +27,7 @@
   }                                                                                                                    \
   static constexpr bool is_valid_##EnumType(int raw_value)                                                             \
   {                                                                                                                    \
-    return raw_value < _XBT_COUNT_ARGS(__VA_ARGS__);                                                                   \
+    return raw_value >= 0 && raw_value < _XBT_COUNT_ARGS(__VA_ARGS__);                                                 \
   }                                                                                                                    \
   enum class EnumType { __VA_ARGS__ } /* defined here to handle trailing semicolon */