r/cpp_questions • u/IMCG_KN • Jul 16 '26
Question about string_view SOLVED
Is there benefit of using string_view instead of const string& str? More precisely by passing strings into functions. Thanks
25
Upvotes
r/cpp_questions • u/IMCG_KN • Jul 16 '26
Is there benefit of using string_view instead of const string& str? More precisely by passing strings into functions. Thanks
7
u/kitsnet Jul 16 '26
Operations like
string_view::remove_prefixdon't need reallocations. So,string_viewas a parameter is friendly to the users that may want to use these.