Вы можете использовать SFINAE для разделения реализации класса перечисления:
template <typename Type,
typename = std::enable_if_t<std::is_enum_v<Type>>>
bool get_bits(Type input, uint8_t offset, uint8_t n, Type* destination) {
// enum-class implementation
}
и интегральной реализации:
template <typename Type,
typename = std::enable_if_t<std::is_integral_v<Type>>>
bool get_bits(Type input, uint8_t offset, uint8_t n, Type* destination) {
// integral implementation
}
Выше приведена версия C ++ 17.
Для C ++ 11 будет что-то вроде:
template <typename Type,
typename std::enable_if<std::is_enum<Type>::value>::type* = nullptr>
bool get_bits(Type input, uint8_t offset, uint8_t n, Type* destination) {
// enum-class implementation
}
template <typename Type,
typename std::enable_if<std::is_integral<Type>::value>::type* = nullptr>
bool get_bits(Type input, uint8_t offset, uint8_t n, Type* destination) {
// integral implementation
}