enum class field access

This commit is contained in:
2025-02-18 19:33:02 +01:00
parent e16ad84865
commit 66835554f1
5 changed files with 20 additions and 8 deletions

View File

@@ -45,6 +45,12 @@ class BitField {
return std::get<FIndex>(this->GetFields()).GetValue();
}
// allow use of enums
template <typename E, E FIndex>
const auto& GetField() const {
return std::get<static_cast<std::size_t>(FIndex)>(this->GetFields()).GetValue();
}
private:
template <int IOffset, typename... T, std::enable_if_t<IOffset >= sizeof...(T), bool> = true>
void Apply(const std::tuple<T...>& args) {}

View File

@@ -119,6 +119,12 @@ class MessageImplFieldsBase : public TBase {
return std::get<FIndex>(GetFields()).GetValue();
}
// allow use of enums
template <typename E, E FIndex>
const auto& GetField() const {
return std::get<static_cast<std::size_t>(FIndex)>(this->GetFields()).GetValue();
}
private:
AllFields m_Fields;
};