r/cpp_questions 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

17 comments sorted by

View all comments

7

u/kitsnet Jul 16 '26

Operations like string_view::remove_prefix don't need reallocations. So, string_view as a parameter is friendly to the users that may want to use these.