Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Won't Do
-
None
Description
Class is basically:
class string_view {
|
const char *string;
|
size_t length;
|
};
|
It's intended to replace all naked char * and const std::string:: & in functions arguments.
string_view is better because of a clear semantics: non-owning string. When you see a member or variable const char *smth; you can't say whether it own its buffer or not. For argument you don't know whether ownership was transferred to function or not. Similar to return char * from function.
string_view makes code easier to read. Also it has begin(), end() member which allows it's data to be used in range-for loops.