I have a string_view:
std::string_view view;
How can I append something like a const char* to it? For example:
std::string_view view = "hello";
view += " world"; // Doesn't work
Also, how can I create a string_view with a specified size?
Like for example:
std::string_view view(100); // Creates a string_view with an initial size of 100 bytes
string_viewis just a view. i.e. the actual object is somewhere else. So you can only 'view' usingstring_view. You cannot append and cannot set the size.string_viewis designed to be usable in many places where astd::stringcan be used, but without needing to copy any data around. It is iteratable, so it can be used with other containers and algorithms that take input iterators. Sub-views can be easily created within astring_viewwithout copying any data. It is just easier to work with than a rawchar*+intpair.