std::string str = "Hello World"; if (str.endswith("ld")) { std::cout << "String ends with 'ld'" << std::endl; }
gsl::cstring_span<> str = "abcdefg"; if (str.endswith("fg")) { std::cout << "String ends with 'fg'" << std::endl; }Output: String ends with 'fg' These examples use the C++ StringRef library, which is part of the GSL (Guidelines Support Library).