From e4c017533ca03c789575302a21efd74bde3a55a4 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 6 May 2024 21:01:55 +0200 Subject: [PATCH] Revert "Use explicitly sized std::array instead of C array and ptr arithmetic" This reverts commit 24321657eeab87bd14a99fc5c43f83adaf4aa78b. --- include/guidance/turn_instruction.hpp | 31 +++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/include/guidance/turn_instruction.hpp b/include/guidance/turn_instruction.hpp index cc70f387e..45ab1f5df 100644 --- a/include/guidance/turn_instruction.hpp +++ b/include/guidance/turn_instruction.hpp @@ -154,21 +154,24 @@ inline bool operator==(const TurnInstruction lhs, const TurnInstruction rhs) inline bool hasRoundaboutType(const TurnInstruction instruction) { using namespace guidance::TurnType; - const constexpr std::array valid_types = {TurnType::EnterRoundabout, - TurnType::EnterAndExitRoundabout, - TurnType::EnterRotary, - TurnType::EnterAndExitRotary, - TurnType::EnterRoundaboutIntersection, - TurnType::EnterAndExitRoundaboutIntersection, - TurnType::EnterRoundaboutAtExit, - TurnType::ExitRoundabout, - TurnType::EnterRotaryAtExit, - TurnType::ExitRotary, - TurnType::EnterRoundaboutIntersectionAtExit, - TurnType::ExitRoundaboutIntersection, - TurnType::StayOnRoundabout}; + const constexpr TurnType::Enum valid_types[] = {TurnType::EnterRoundabout, + TurnType::EnterAndExitRoundabout, + TurnType::EnterRotary, + TurnType::EnterAndExitRotary, + TurnType::EnterRoundaboutIntersection, + TurnType::EnterAndExitRoundaboutIntersection, + TurnType::EnterRoundaboutAtExit, + TurnType::ExitRoundabout, + TurnType::EnterRotaryAtExit, + TurnType::ExitRotary, + TurnType::EnterRoundaboutIntersectionAtExit, + TurnType::ExitRoundaboutIntersection, + TurnType::StayOnRoundabout}; - return std::find(valid_types.cbegin(), valid_types.cend(), instruction.type); + const auto *first = valid_types; + const auto *last = first + sizeof(valid_types) / sizeof(valid_types[0]); + + return std::find(first, last, instruction.type) != last; } inline bool entersRoundabout(const guidance::TurnInstruction instruction)