Lifetime Concerns with std::string_view in OpenDriveRoadPosition and OpenDriveLanePosition
Recently, we noticed that the type of the road variable in the OpenDriveRoadPosition and OpenDriveLanePosition structures has been changed to std::string_view. This change was made to avoid memory allocation and ensure constancy, which can be beneficial for performance and safety.
This situation poses a challenge because std::string_view only provides a non-owning view of the data and depends on the existence of the original string throughout its usage. When the original string is destroyed by the stateless coordinate conversion function, any subsequent access to the std::string_view becomes invalid and leads to undefined behavior.
Possible solutions may keeping the original strings alive for the duration of their usage (store state in the map engine) or considering alternative string representations in cases where the lifetime of the data cannot be guaranteed.
Please provide feedback and suggestions on how to handle this situation.