I have a binary data file which I read into a struct. This struct has some enum class, but there is a small possibility that the data readed is incorrect or corrupted, which would result in values out of the range.
Request
With C++20 we have std::in_range. One possibility would be for me to implement the needed operators to use std::in_range or add a enum value called "MAX_VALUE" or alike and check all enum values are less than that. Also, magic_enum has magic_enum::enum_contains which could be used for this purposes. But still, the API seems to be designed for a different use case, so I think it could be useful to add an API for validating an enum.
Use case
I have a binary data file which I read into a struct. This struct has some enum class, but there is a small possibility that the data readed is incorrect or corrupted, which would result in values out of the range.
Request
With C++20 we have std::in_range. One possibility would be for me to implement the needed operators to use std::in_range or add a enum value called "MAX_VALUE" or alike and check all enum values are less than that. Also, magic_enum has
magic_enum::enum_contains
which could be used for this purposes. But still, the API seems to be designed for a different use case, so I think it could be useful to add an API for validating an enum.Thank you very much