如何使用 boost 字符串算法 starts_with:最小示例

boost_starts_with.cpp
#include <boost/algorithm/string/predicate.hpp>
#include <string>
#include <iostream>

int main() {
    std::string mystr = "foobar";
    // 打印 "true, false"
    std::cout << std::boolalpha
        << boost::algorithm::starts_with(mystr, "foo") << ", "
        << boost::algorithm::starts_with(mystr, "bar") << std::endl;
}

另请参阅:如何使用 boost 字符串算法 ends_with:最小示例


Check out similar posts by category: Boost, C/C++