@@ -27,14 +27,24 @@ namespace {
2727 return false ;
2828 }
2929
30- std::byte operator +(const std::byte & lhs, const std::byte &rhs) {
30+ std::byte operator +(const std::byte lhs, const std::byte &rhs) {
3131 return std::byte {static_cast <std::uint8_t >(static_cast <int >(lhs) + static_cast <int >(rhs))};
3232 }
3333
3434 // This madness should be removed once the minimum compiler version increases...
3535 std::byte logicalAnd (const std::byte &lhs, const std::byte &rhs) {
3636 return std::byte {static_cast <std::uint8_t >(static_cast <int >(lhs) & static_cast <int >(rhs))};
3737 }
38+
39+ // This madness should be removed once the minimum compiler version increases...
40+ std::byte shiftLeft (const std::byte &lhs, const int rhs) {
41+ return std::byte {static_cast <std::uint8_t >(static_cast <int >(lhs) << rhs)};
42+ }
43+
44+ // This madness should be removed once the minimum compiler version increases...
45+ std::byte shiftRight (const std::byte &lhs, const int rhs) {
46+ return std::byte {static_cast <std::uint8_t >(static_cast <int >(lhs) >> rhs)};
47+ }
3848} // namespace
3949
4050namespace display_device {
@@ -86,12 +96,12 @@ namespace display_device {
8696 {
8797 constexpr std::byte ascii_offset {' @' };
8898
89- auto byte_a {data[8 ]};
90- auto byte_b {data[9 ]};
99+ const auto byte_a {data[8 ]};
100+ const auto byte_b {data[9 ]};
91101 std::array<char , 3 > man_id {};
92102
93- man_id[0 ] = static_cast <char >(ascii_offset + (logicalAnd (byte_a, std::byte {0x7C }) >> 2 ));
94- man_id[1 ] = static_cast <char >(ascii_offset + (logicalAnd (byte_a, std::byte {0x03 }) << 3 ) + (logicalAnd (byte_b, std::byte {0xE0 }) >> 5 ));
103+ man_id[0 ] = static_cast <char >(ascii_offset + shiftRight (logicalAnd (byte_a, std::byte {0x7C }), 2 ));
104+ man_id[1 ] = static_cast <char >(ascii_offset + shiftLeft (logicalAnd (byte_a, std::byte {0x03 }), 3 ) + shiftRight (logicalAnd (byte_b, std::byte {0xE0 }), 5 ));
95105 man_id[2 ] = static_cast <char >(ascii_offset + logicalAnd (byte_b, std::byte {0x1F }));
96106
97107 for (const char ch : man_id) {
0 commit comments