Daily bit(e) of C++

Share this post

Daily bit(e) of C++ | std::string_view

simontoth.substack.com

Daily bit(e) of C++ | std::string_view

Daily bit(e) of C++ #257, The borrowed range for strings: std::string_view.

Šimon Tóth
Sep 15, 2023
3
Share this post

Daily bit(e) of C++ | std::string_view

simontoth.substack.com
Share

The std::string_view is a borrowed range that can reference any (not necessarily null-terminated) string, i.e. string literals, std::string and other character contiguous ranges.

std::string_view should be preferred over an immutable std::string, except for cases when ownership is also required, as std::string_view can only reference data owned by other ranges.

Click to open in Compiler Explorer.

Leave a comment

Thanks for reading Daily bit(e) of C++! Subscribe for free to receive new posts and support my work.

3
Share this post

Daily bit(e) of C++ | std::string_view

simontoth.substack.com
Share
Comments
Top
New
Community

No posts

Ready for more?

© 2023 Šimon Tóth
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing