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,32 +26,28 @@ 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} {} 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) inline Face merge_faces(const Face& base, const Face& face)
{ {
auto choose = [&](Color Face::*color, Attribute final_attr) { auto choose = [&](Color Face::*color, Attribute final_attr) {