| You're missing a bunch of very important stuff in that page you linked to. See what they listed as the culprits: > strings being passed as char* (using c_str()) and then converted back to string > Using a temporary set [...] only to call find on it to return true/false > Not reserving space in a vector c_str() isn't there for "good performance" to begin with; it's there for interfacing with C APIs. RAII or not, GC or not, you don't convert to/from C strings in C++ unless you have to. The other stuff above have nothing to do with C++ or pointers, you'd get the same slowdowns in any language. The language has come a long way since 2014. Notice what they said the solutions are: > base::StringPiece [...] a.k.a., C++17's std::string_view. |
My argument was that for efficient code, you need to pass references or pointers, which means you do need to care about lifetimes.
And your argument is that's not true because we now have std::string_view? You do realize that it's just a pointer and a length, right? And that this means you need to consider how long the string_view is valid etc., just as carefully as you would for any other pointer?