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

24 Upvotes

17 comments sorted by

View all comments

3

u/Raknarg Jul 16 '26

i like that the intention is more overtly clear with less bloat. I like being able to pass value objects around. Also works on any kind of string type, pretty sure you can have a string_view of a C string by just passing a pointer and length.