std::ranges::ends_with
cppreference.com
Example
main: () = {
static_assert(
true
&& !std::ranges::ends_with("for", "cast")
&& std::ranges::ends_with("dynamic_cast", "cast")
&& !std::ranges::ends_with("as_const", "cast")
&& std::ranges::ends_with("bit_cast", "cast")
&& !std::ranges::ends_with("to_underlying", "cast")
&& std::ranges::ends_with(:std::array=(1, 2, 3, 4), :std::array=(3, 4))
&& !std::ranges::ends_with(:std::array=(1, 2, 3, 4), :std::array=(4, 5))
);
using std::literals::_;
std::cout << std::boolalpha
<< std::ranges::ends_with("Constantinopolis"sv, "polis"sv) << ' '
<< std::ranges::ends_with("Istanbul"sv, "polis"sv) << ' '
<< std::ranges::ends_with("Metropolis"sv, "polis"sv) << ' '
<< std::ranges::ends_with("Acropolis"sv, "polis"sv) << '\n';
}
Output