Create and initialise
You can create an empty string view. You can also create a string view from an existing string, an existing character-array, or an existing string view.
The table below gives you an overview of the various ways of creating a string view.
Methods | Example |
---|---|
Empty string view | std::string_view str_view |
From a C-string | std::string_view str_view2("C-string") |
From a string view | std::string_view str_view3(str_view2) |
From a C array | std::string_view str_view4(arr, sizeof arr) |
From a string_view | str_view4= str_view3.substring(2, 3) |
From a string view | std::string_view str_view5 = str_view4 |