Small code cleanup in Face struct definition

This commit is contained in:
Maxime Coste 2019-04-18 14:37:24 +02:00
parent 06d4ee578e
commit aec58b968b

View File

@ -26,31 +26,27 @@ constexpr bool with_bit_ops(Meta::Type<Attribute>) { return true; }
struct Face struct Face
{ {
Color fg; Color fg = Color::Default;
Color bg; Color bg = Color::Default;
Attribute attributes; Attribute attributes = Attribute::Normal;
constexpr Face(Color fg = Color::Default, Color bg = Color::Default, friend constexpr bool operator==(const Face& lhs, const Face& rhs)
Attribute attributes = Attribute::Normal) {
: fg{fg}, bg{bg}, attributes{attributes} {}
};
constexpr bool operator==(const Face& lhs, const Face& rhs)
{
return lhs.fg == rhs.fg and return lhs.fg == rhs.fg and
lhs.bg == rhs.bg and lhs.bg == rhs.bg and
lhs.attributes == rhs.attributes; lhs.attributes == rhs.attributes;
} }
constexpr bool operator!=(const Face& lhs, const Face& rhs) friend constexpr bool operator!=(const Face& lhs, const Face& rhs)
{ {
return not (lhs == rhs); return not (lhs == rhs);
} }
constexpr size_t hash_value(const Face& val) friend constexpr size_t hash_value(const Face& val)
{ {
return hash_values(val.fg, val.bg, val.attributes); return hash_values(val.fg, val.bg, val.attributes);
} }
};
inline Face merge_faces(const Face& base, const Face& face) inline Face merge_faces(const Face& base, const Face& face)
{ {