How exactly is std::string_view faster than const std::string&?

std::string_view has made it to C++17 and it is widely recommended to use it instead of const std::string&.

One of the reasons is performance.

Can someone explain how exactly std::string_view is/will be faster than const std::string& when used as a parameter type? (let’s assume no copies in the callee are made)

5 Answers
5

Leave a Comment