Skip to content

Commit a027c45

Browse files
Explicitly check value of optional in rich enum constants macro
1 parent 889f671 commit a027c45

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

include/fixed_containers/enum_utils.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ using RichEnumStorage = std::conditional_t<std::is_same_v<std::underlying_type_t
373373
#define FIXED_CONTAINERS_RICH_ENUM_CONSTANT_GEN_HELPER(RichEnumName, CONSTANT_NAME) \
374374
static constexpr RichEnumName CONSTANT_NAME() /* NOLINT(readability-identifier-naming) */ \
375375
{ \
376-
return RichEnumName::value_of(BackingEnum::CONSTANT_NAME).value(); \
376+
const auto& value_of = RichEnumName::value_of(BackingEnum::CONSTANT_NAME); \
377+
::fixed_containers::assert_or_abort(value_of.has_value()); \
378+
return value_of.value(); \
377379
}
378380

379381
namespace fixed_containers::rich_enums

0 commit comments

Comments
 (0)