Use explicitly sized std::array instead of C array and ptr arithmetic

This commit is contained in:
Dennis Luxen 2024-05-06 21:00:45 +02:00
parent e17d1d6580
commit 24321657ee

View File

@ -154,24 +154,21 @@ inline bool operator==(const TurnInstruction lhs, const TurnInstruction rhs)
inline bool hasRoundaboutType(const TurnInstruction instruction)
{
using namespace guidance::TurnType;
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};
const constexpr std::array<TurnType::Enum, 13> 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 auto *first = valid_types;
const auto *last = first + sizeof(valid_types) / sizeof(valid_types[0]);
return std::find(first, last, instruction.type) != last;
return std::find(valid_types.cbegin(), valid_types.cend(), instruction.type);
}
inline bool entersRoundabout(const guidance::TurnInstruction instruction)