This produces a better error message than a static_assert failure, since
gcc points directly to the call which resolved to the deleted overload.
When the caller is correct, this produces the same result as the prior
version.
Add a helper to deduce the enum type of a value, and use an appropriate
std::underlying_type<T> expression for that enum type. This avoids the
need to repeat the type of the enum at the site of each cast, and moves
the casts into the helper to make the callers easier to read.