https://en.cppreference.com/w/cpp/string/basic_string
cpp
#include <iostream>
#include <string>
#include <format>
void test_01()
{
int val = std::stoi("101");
std::cout << std::format("{}\n", val); // 101
std::string str("Hello C++20!");
if(str.ends_with("C++20!")){
std::cout << std::format("{} ends with \"{}\"\n",str, "C++20!"); // Hello C++20! ends with "C++20!"
}
if(str.starts_with("Hello")){
std::cout << std::format("{} starts with \"{}\"\n",str, "Hello"); // Hello C++20! ends with "C++20!"
}
if(str.contains("C++23")){
std::cout << std::format("{} contains \"{}\"\n",str, "C++23");
}
else {
// std::basic_string<CharT,Traits,Allocator>::contains is supported from "C++23".
std::cout << std::format("std::basic_string<CharT,Traits,Allocator>::contains is supported from \"{}\".\n", "C++23");
}
}
int main()
{
test_01();
}