This example demonstrates how to use std::string_view::size() to get the size of a string_view.
Package library: STL
Example 2:
c++
#include
#include
void printStringViewSize(std::string_view sv) {
std::cout << "The size of the string_view is: " << sv.size() << std::endl;
}
int main() {
std::string_view sv1("hello");
std::string_view sv2("world");
printStringViewSize(sv1); // Output: The size of the string_view is: 5
printStringViewSize(sv2); // Output: The size of the string_view is: 5
return 0;
}
```
This example shows how to pass a string_view to a function that calls std::string_view::size() to get its size.
Package library: STL
C++ (Cpp) string_view::size - 30 examples found. These are the top rated real world C++ (Cpp) examples of std::string_view::size extracted from open source projects. You can rate examples to help us improve the quality of examples.