STL std::string_view and when to use it versus std::string | Modern Cpp Series Ep. 113

preview_player
Показать описание

►Lesson Description: In this lesson I show you how to use STL string_view to provide a faster way to access strings (especially when only performing read-only operations).

►Please like and subscribe to help the channel!
Рекомендации по теме
Комментарии
Автор

Thanks for using the term "pass by copy", which really makes so much more sense than saying "pass by value". It explicitly states what is being passed. And it may be even better to say "pass a copy" to the function, and "pass a reference".😁

qcnck
Автор

I am starting to watch STL from beginning. such an amazing content! Thanks for your time and effort!

thestarinthesky_
Автор

Great explanation; I have always wondered about the need for this. I have now confirmed based on your excellent explanation that by just using a const &, there is no need for this. In fact by passing a const reference you are pushing fewer bytes to the function you're calling than by passing a string_view copy. So much redundant functionality has been added ti the C++ language over the years but really useful things like better RTTI/reflection hasn't been.

Aquineas
Автор

Not sure I really get the benefit of string_view; passing the initial std::string by ref should be as efficient as can be (?) OFC, if you need to have a char* on the caller site first, then I agree. But why this detour?

bsdooby
Автор

Pls help me cuz <string_view> is not available in my c++ version, cuz it gives the red line under the text in vs code.

How do I fix this?

Gust
visit shbcf.ru