Passing a string temporary into a string_view can make the latter dangling
Safely passing std::strings and std::string_view
by Niek J Bouman
From the article:
Many of you will agree that C++ is a language that comes with sharp edges. One example is `std::string_view`; introduced as a type to prevent unnecessary std::string-copies, but it introduces a new footgun, namely when passing a temporary string into it:
Add a Comment