diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-04-18 14:37:24 +0200 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-04-18 14:37:24 +0200 |
| commit | aec58b968b10c82210af882d30b61be8bc8e22eb (patch) | |
| tree | bf370aae4294fdcba1449747373a685d1616b522 /src/face.hh | |
| parent | 06d4ee578e5955d3d444bbe9dd03285df958cdd1 (diff) | |
Small code cleanup in Face struct definition
Diffstat (limited to 'src/face.hh')
| -rw-r--r-- | src/face.hh | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/face.hh b/src/face.hh index d2a3af93..962b8076 100644 --- a/src/face.hh +++ b/src/face.hh @@ -26,31 +26,27 @@ constexpr bool with_bit_ops(Meta::Type<Attribute>) { return true; } struct Face { - Color fg; - Color bg; - Attribute attributes; + Color fg = Color::Default; + Color bg = Color::Default; + Attribute attributes = Attribute::Normal; - constexpr Face(Color fg = Color::Default, Color bg = Color::Default, - Attribute attributes = Attribute::Normal) - : fg{fg}, bg{bg}, attributes{attributes} {} -}; + friend constexpr bool operator==(const Face& lhs, const Face& rhs) + { + return lhs.fg == rhs.fg and + lhs.bg == rhs.bg and + lhs.attributes == rhs.attributes; + } -constexpr bool operator==(const Face& lhs, const Face& rhs) -{ - return lhs.fg == rhs.fg and - lhs.bg == rhs.bg and - lhs.attributes == rhs.attributes; -} + friend constexpr bool operator!=(const Face& lhs, const Face& rhs) + { + return not (lhs == rhs); + } -constexpr bool operator!=(const Face& lhs, const Face& rhs) -{ - return not (lhs == rhs); -} - -constexpr size_t hash_value(const Face& val) -{ - return hash_values(val.fg, val.bg, val.attributes); -} + friend constexpr size_t hash_value(const Face& val) + { + return hash_values(val.fg, val.bg, val.attributes); + } +}; inline Face merge_faces(const Face& base, const Face& face) { |
