I want to check if a constexpr number is in a constexpr array at compile time. If not, stop compiling. My ideographic example:
constexpr void PinValid(uint8_t Pin)
{
constexpr uint8_t ValidPins[] = {2, 3, 18, 19, 20, 21};
for (uint8_t P : ValidPins)
if (Pin == P)
return;
static_assert(false);
}
This code fails for any given Pin even if it is in the ValidPins.
static_assert(false)will always fail at compile time.