From aec58b968b10c82210af882d30b61be8bc8e22eb Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 18 Apr 2019 14:37:24 +0200 Subject: [PATCH] Small code cleanup in Face struct definition --- src/face.hh | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/face.hh b/src/face.hh index d2a3af93..962b8076 100644 --- a/src/face.hh +++ b/src/face.hh @@ -26,32 +26,28 @@ constexpr bool with_bit_ops(Meta::Type) { 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; + } + + friend constexpr bool operator!=(const Face& lhs, const Face& rhs) + { + return not (lhs == rhs); + } + + friend constexpr size_t hash_value(const Face& val) + { + return hash_values(val.fg, val.bg, val.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; -} - -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); -} - inline Face merge_faces(const Face& base, const Face& face) { auto choose = [&](Color Face::*color, Attribute final_attr) {