2 ms·
This is a different issue. You could have replaced the ternary with if constexpr in a lambda, but it's very verbose. I saw some people to propose that ternary
by planede 4y ago
This is a different issue. You could have replaced the ternary with if constexpr in a lambda, but it's very verbose.
I saw some people to propose that ternary should work potentially like if constexpr, if the condition is a constant expression. Honestly, IMO the ternary operator is already cursed, and it should not be overloaded with more responsibility.
I think this should work without nonsense return types:
static constexpr auto readBucket = []{
if constexpr (BYTES_PER_LEVEL == 2) {
return readTwoBytes<idx, udigit>;
} else {
return readOneByte<idx, udigit>;
}
}();