YOUR AD GOES HERE

Improve String Performance With std::string_view

Published 31, Oct 2026

emcapsulation


Description:
std::string_view (C++17) is a non-owning read-only view of a sequence of characters. This can be beneficial in reducing unecessary copies of character data when passing strings into functions or performing parsing (e.g. using the .substr function). String views don't allocate the character data; they refer to an existing character sequence.

However there are a couple of pitfalls to be aware of. As string_view is a simple view of existing data, the data which it refers to must remain valid for the duration of the string_view. I give an example here of returning a string_view from a function where the underlying string data is destroyed on return.

Releted More Videos

  • Sorry!!! Nothing to show

You May Also Like

YOUR AD GOES HERE

YOUR AD GOES HERE