Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Or this:

for (std::string_view arg : config.version_script) parse_version_script(std::string(arg));



Although if somehow nothing gets really freed, and std::string() is kept intact after calling the destructor (e.g. it's data() is still valid) then it'll work :)


`parse_version_script` is defined as taking an `std::string`, std::string() over an `std::string_view` will create a new std::string with a copy of the data from arg.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: