enum class field access
This commit is contained in:
@@ -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) {}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user