Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
BLE: Fix SafeEnum type safety #9393
The relational operators were targeting the base class which defines an implicit constructor to an integral value. This is wrong as it allows SafeEnum instances to be compared against integers.
The fix is simple: define relationnal operators for the derived class. The derived class is known as it is passed as a template parameter of the base class.
Pull request type
Actually, isn't it still a good idea to put an 'explicit' on the
@kjbracey-arm Yes, that's a good idea to mark it as explicit. I don't recall why it wasn't (maybe just a mistake!) and tried it within our codebase and it doesn't yield any error. Going further I marked that constructor as protected as clients do not have any business in constructing SafeEnum outside a derived class.