Browse Source

Simplify `ColumnDefinition` using C++20 features

1. Default comparison: https://en.cppreference.com/w/cpp/language/default_comparisons
2. Parentheses initialization for aggregate types
pull/6558/head
Gleb Mazovetskiy 3 years ago
parent
commit
9bbc138b0f
  1. 25
      Source/data/file.hpp

25
Source/data/file.hpp

@ -11,35 +11,16 @@
namespace devilution {
struct ColumnDefinition {
uint8_t type;
enum class Error {
UnknownColumn
};
uint8_t type = std::numeric_limits<uint8_t>::max();
// The number of fields between this column and the last one identified as important (or from start of the record if this is the first column we care about)
unsigned skipLength = 0;
ColumnDefinition()
: type(std::numeric_limits<uint8_t>::max())
{
}
ColumnDefinition(unsigned type)
: type(type)
{
}
ColumnDefinition(unsigned type, unsigned skipLength)
: type(type)
, skipLength(skipLength)
{
}
bool operator==(const ColumnDefinition &other) const
{
return type == other.type && skipLength == other.skipLength;
}
bool operator==(const ColumnDefinition &other) const = default;
template <typename T>
explicit operator T() const

Loading…
Cancel
Save