#include <boost/algorithm/string/predicate.hpp> #include <string> #include <iostream> int main() { std::string mystr = "foobar"; // Prints "false, true" std::cout << std::boolalpha << boost::algorithm::ends_with(mystr, "foo") << ", " << boost::algorithm::ends_with(mystr, "bar") << std::endl; }
Also see: How to use boost string algorithm starts_with: A minimal example