mirror of https://github.com/OpenTTD/OpenTTD
Codechange: make EnumBitSet ConvertibleThroughBase
parent
55588b052e
commit
b6a092f3e0
|
@ -117,8 +117,8 @@ debug_inline constexpr void ToggleFlag(T &x, const T y)
|
|||
template <typename Tenum, typename Tstorage>
|
||||
class EnumBitSet {
|
||||
public:
|
||||
using enum_type = Tenum; ///< Enum type of this EnumBitSet.
|
||||
using storage_type = Tstorage; ///< Storage type of this EnumBitSet.
|
||||
using EnumType = Tenum; ///< Enum type of this EnumBitSet.
|
||||
using BaseType = Tstorage; ///< Storage type of this EnumBitSet, be ConvertibleThroughBase
|
||||
|
||||
constexpr EnumBitSet() : data(0) {}
|
||||
constexpr EnumBitSet(Tenum value) : data(0) { this->Set(value); }
|
||||
|
|
|
@ -35,9 +35,6 @@ public:
|
|||
EndianBufferWriter &operator <<(std::string_view data) { this->Write(data); return *this; }
|
||||
EndianBufferWriter &operator <<(bool data) { return *this << static_cast<uint8_t>(data ? 1 : 0); }
|
||||
|
||||
template <typename Tenum, typename Tstorage>
|
||||
EndianBufferWriter &operator <<(const EnumBitSet<Tenum, Tstorage> &data) { return *this << data.base(); }
|
||||
|
||||
template <typename T>
|
||||
EndianBufferWriter &operator <<(const OverflowSafeInt<T> &data) { return *this << static_cast<T>(data); };
|
||||
|
||||
|
@ -136,9 +133,6 @@ public:
|
|||
EndianBufferReader &operator >>(std::string &data) { data = this->ReadStr(); return *this; }
|
||||
EndianBufferReader &operator >>(bool &data) { data = this->Read<uint8_t>() != 0; return *this; }
|
||||
|
||||
template <typename Tenum, typename Tstorage>
|
||||
EndianBufferReader &operator >>(EnumBitSet<Tenum, Tstorage> &data) { data = Tenum{this->Read<Tstorage>()}; return *this; }
|
||||
|
||||
template <typename T>
|
||||
EndianBufferReader &operator >>(OverflowSafeInt<T> &data) { data = this->Read<T>(); return *this; };
|
||||
|
||||
|
|
Loading…
Reference in New Issue