diff --git a/include/esc/brush.hpp b/include/esc/brush.hpp index 4e022d5..f9c276b 100644 --- a/include/esc/brush.hpp +++ b/include/esc/brush.hpp @@ -14,5 +14,20 @@ struct Brush { Traits traits = Traits{Trait::None}; }; +/// Returns true if the two Brushes have the same background, foreground, and +/// traits. +[[nodiscard]] inline auto operator==(Brush const& lhs, Brush const& rhs) -> bool +{ + return lhs.background == rhs.background && + lhs.foreground == rhs.foreground && lhs.traits == rhs.traits; +} + +/// Returns true if the two Brushes do not have the same background, foreground, +/// and traits. +[[nodiscard]] inline auto operator!=(Brush const& lhs, Brush const& rhs) -> bool +{ + return !(lhs == rhs); +} + } // namespace esc #endif // ESC_BRUSH_HPP diff --git a/include/esc/default_color.hpp b/include/esc/default_color.hpp index 66d374d..7026b7b 100644 --- a/include/esc/default_color.hpp +++ b/include/esc/default_color.hpp @@ -5,6 +5,18 @@ namespace esc { /// Default Color of the terminal. struct Default_color {}; +/// Checks for equality, always returns true. +[[nodiscard]] constexpr auto operator==(Default_color, Default_color) -> bool +{ + return true; +} + +/// Checks for inequality, always returns false. +[[nodiscard]] constexpr auto operator!=(Default_color, Default_color) -> bool +{ + return false; +} + /// Tag type for terminal default color background. struct BG_Default_color {}; diff --git a/include/esc/true_color.hpp b/include/esc/true_color.hpp index fa3acf6..2a6ab2f 100644 --- a/include/esc/true_color.hpp +++ b/include/esc/true_color.hpp @@ -132,6 +132,20 @@ class True_color { constexpr True_color(HSL x) : True_color{hsl_to_rgb(x)} {} }; +/// Returns true if the two True_colors are the same. +[[nodiscard]] inline auto operator==(True_color const& lhs, + True_color const& rhs) -> bool +{ + return lhs.red == rhs.red && lhs.green == rhs.green && lhs.blue == rhs.blue; +} + +/// Returns true if the two True_colors are not the same. +[[nodiscard]] inline auto operator!=(True_color const& lhs, + True_color const& rhs) -> bool +{ + return !(lhs == rhs); +} + /// Tag type for True_color that is used as a background. struct BG_True_color { True_color value;