Suppose I need to call a function foo that takes a const std::string reference from a great number of places in my code:
int foo(const
If that function foo does not make a copy of the string then its interface is sub-optimal. It is better to change it to accept char const* or string_view, so that the caller is not required to construct std::string.
Or add overloads:
void foo(char const* str, size_t str_len); // Does real work.
inline void foo(std::string const& s) { foo(s.data(), s.size()); }
inline void foo(char const* s) { foo(s, strlen(s)); }