3 ms·
Arguably an explicit type would have made the bug a little bit more obvious. You basically expect, by default, this kind of string manipulation functions to ret
by LaLaLand122 4y ago
Arguably an explicit type would have made the bug a little bit more obvious. You basically expect, by default, this kind of string manipulation functions to return a std::string. Obviously in this specific case you can return a view, and that makes it more performant; but it's kind of unexpected and using auto leaves the surprise a bit more hidden.
But sure, you can still make the error with expiclit types.
- hot_gril 4y agoI agree, the string_view on the LHS might make you think more about the lifetime, but I'm pretty sure we all would've missed it.