Static checks for guidance array sizes.
This commit is contained in:
@@ -68,7 +68,8 @@ inline bool hasValidLanes(const guidance::Intersection &intersection)
|
||||
|
||||
std::string instructionTypeToString(const TurnType::Enum type)
|
||||
{
|
||||
BOOST_ASSERT(static_cast<std::size_t>(type) < sizeof(turn_type_names)/sizeof(turn_type_names[0]));
|
||||
static_assert(sizeof(turn_type_names)/sizeof(turn_type_names[0]) >= TurnType::MaxTurnType,
|
||||
"Some turn types has not string representation.");
|
||||
return turn_type_names[static_cast<std::size_t>(type)];
|
||||
}
|
||||
|
||||
@@ -98,11 +99,15 @@ util::json::Array lanesFromIntersection(const guidance::Intersection &intersecti
|
||||
|
||||
std::string instructionModifierToString(const DirectionModifier::Enum modifier)
|
||||
{
|
||||
static_assert(sizeof(modifier_names)/sizeof(modifier_names[0]) >= DirectionModifier::MaxDirectionModifier,
|
||||
"Some direction modifiers has not string representation.");
|
||||
return modifier_names[static_cast<std::size_t>(modifier)];
|
||||
}
|
||||
|
||||
std::string waypointTypeToString(const guidance::WaypointType waypoint_type)
|
||||
{
|
||||
static_assert(sizeof(waypoint_type_names)/sizeof(waypoint_type_names[0]) >= static_cast<size_t>(guidance::WaypointType::MaxWaypointType),
|
||||
"Some waypoint types has not string representation.");
|
||||
return waypoint_type_names[static_cast<std::size_t>(waypoint_type)];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user