llvm::StringRef str = "Hello, World!"; std::size_t size = str.size(); std::cout << "Size of the string: " << size << "\n";
llvm::StringRef str = "The quick brown fox jumps over the lazy dog."; llvm::StringRef subStr = "brown"; if (str.contains(subStr)) { std::cout << "Found substring: " << subStr << "\n"; }This example shows how to use a StringRef to search for a substring. The contains() method checks whether the string slice contains the given substring. Package library: LLVM.