From 66cdf9b2a5bb6da31f3091a52ff4618c0a333011 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Sun, 26 Sep 2021 17:42:03 +0200 Subject: [PATCH] Fix: box drawing comparison. There was a bug. Converting the bitfield to int using the union wasn't working correctly. --- src/ftxui/screen/screen.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index f323c50..9e94589 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -98,16 +98,21 @@ struct TileEncoding { unsigned int down : 2; unsigned int round : 1; + // clang-format off bool operator<(const TileEncoding& other) const { - union Converter { - TileEncoding input; - uint16_t output = 0; - }; - Converter a, b; - a.input = *this; - b.input = other; - return a.output < b.output; + if (left < other.left) return true; + if (left > other.left) return false; + if (top < other.top) return true; + if (top > other.top) return false; + if (right < other.right) return true; + if (right > other.right) return false; + if (down < other.down) return true; + if (down > other.down) return false; + if (round < other.round) return true; + if (round > other.round) return false; + return false; } + // clang-format on }; // clang-format off