Hacker News new | past | comments | ask | show | jobs | submit login

Copying into a string is a safe default. Also, proto’s API currently returns string references (and not views) so making a copy is required for open source.

(Although now std::string_view is common, I hear rumors that the proto API might change…)




I don't think it was about safety. It was because they didn't want to make ABSL part of the public API.


Maybe that's true, but safety is an additional concern. You have way more lifetime headaches if you alias the underlying data. Copying avoids all that.




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

Search: