From dcac185049c0f89d16276805c13f461a7b8235d3 Mon Sep 17 00:00:00 2001 From: Adrian Conlon <98398945+AdrianConlon@users.noreply.github.com> Date: Fri, 1 Jul 2022 09:11:28 +0100 Subject: [PATCH] Reuse device match --- inc/Device.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/Device.h b/inc/Device.h index 1647d0f..d9b4e7b 100644 --- a/inc/Device.h +++ b/inc/Device.h @@ -96,15 +96,15 @@ namespace EightBit { public: [[nodiscard]] static constexpr auto raised(const PinLevel line) noexcept { return line == PinLevel::High; } - static constexpr void raise(PinLevel& line) noexcept { line = PinLevel::High; } + static constexpr void raise(PinLevel& line) noexcept { match(line, PinLevel::High); } [[nodiscard]] static constexpr auto lowered(const PinLevel line) noexcept { return line == PinLevel::Low; } - static constexpr void lower(PinLevel& line) noexcept { line = PinLevel::Low; } + static constexpr void lower(PinLevel& line) noexcept { match(line, PinLevel::Low); } static constexpr void match(PinLevel& line, int condition) noexcept { match(line, condition != 0); } static constexpr void match(PinLevel& line, bool condition) noexcept { condition ? raise(line) : lower(line); } static constexpr void match(PinLevel& out, PinLevel in) noexcept { out = in; } - static constexpr void flip(PinLevel& out) noexcept { out = out == PinLevel::Low ? PinLevel::High : PinLevel::Low; } + static constexpr void flip(PinLevel& out) noexcept { match(out, out == PinLevel::Low ? PinLevel::High : PinLevel::Low); } virtual ~Device() noexcept {};