From 9bbc138b0ffb7e3f2522e7d3ab5e420a780d0ec8 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 3 Sep 2023 00:47:34 +0100 Subject: [PATCH] Simplify `ColumnDefinition` using C++20 features 1. Default comparison: https://en.cppreference.com/w/cpp/language/default_comparisons 2. Parentheses initialization for aggregate types --- Source/data/file.hpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/Source/data/file.hpp b/Source/data/file.hpp index 6c182ae36..c2b67ee89 100644 --- a/Source/data/file.hpp +++ b/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::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::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 explicit operator T() const