From e7fe7ff49fea70e97becf23f247dfe776b91e3ca Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 24 Aug 2019 22:47:06 -0400 Subject: [PATCH] MIDIDecoder: Make use of std::clamp() within clamp7() We can simplify the implementation of clamp7() with the use of std::clamp(). --- lib/audiodev/MIDIDecoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/audiodev/MIDIDecoder.cpp b/lib/audiodev/MIDIDecoder.cpp index 551323b..40eca9c 100644 --- a/lib/audiodev/MIDIDecoder.cpp +++ b/lib/audiodev/MIDIDecoder.cpp @@ -9,7 +9,7 @@ namespace boo { namespace { -constexpr uint8_t clamp7(uint8_t val) { return std::max(0, std::min(127, int(val))); } +constexpr uint8_t clamp7(uint8_t val) { return std::clamp(val, uint8_t{0}, uint8_t{127}); } std::optional readContinuedValue(std::vector::const_iterator& it, std::vector::const_iterator end) {