Should methods returning const std::string& return const std::string_view instead?
问题 Assume we have a simple getter method in a class that returns a const reference to a std::string member: const std::string& getString() const noexcept { return someString; } With the advent of std::string_view in C++17, I wonder whether it has any advantages of writing this instead: const std::string_view getString() const noexcept { return someString; } Does one method have advantages/disadvantages over the other? Clearly (correct me if I'm wrong) both solutions will definitely be better