Suppose I have a class which has a std::string member, and I want to take the value for this member in one of its constructors.
One approach is to take a parameter of type std::string and then use std::move:
Foo(std::string str) : _str(std::move(str)) {}
As far as I understand it, moving a string just copies its internal pointers meaning its basically free, so passing a const char* will be as efficient as passing a const std::string&.
However in C++17 we got std::string_view, with its promise of cheap copies. So the above could be written as:
Foo(std::string_view str) : _str(str.begin(), str.end()) {}
No need for moves or constructing temporary std::string's, but I think it actually just does effectively the same thing as before.
So is there something I am missing here? Or is it just a matter of style as to whether you use std::string_view or std::string with move?