- 基本概念
1.1 all的基本情况
-
基本作用
boost::algorithm::all()是一个模板方法,如基本语法所写,给定的"容器参数"(RangT)中的所有的元素,都满足一个固定的“条件”(PredicateT)。在代码示例中,即字符串容器下的每个字符都满足is_lower()(字符小写),如果全部满足,则返回true,否则返回false.
-
基本语法
// In header: <boost/algorithm/string/predicate.hpp>
template<typename RangeT, typename PredicateT>
bool all(const RangeT & Input, PredicateT Pred);
1.2 is_lower的基本情况
- 基本作用
boost::algorithm::is_lower(),只是字符是否是小写
- 基本语法
// In header: <boost/algorithm/string/classification.hpp>
unspecified is_lower(const std::locale & Loc = std::locale());
2. 头文件
#include<boost/algorithm/string.hpp>
3. 简单代码
#include <iostream>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
#include <string>
using namespace std;
char text[] = "hello";
int main()
{
// 开始的时候,参考网络练习,is_lower()前面没有写域前缀(boost::algorithm::
//is_lower()) ,报错误,说没有is_lower()定义
bool is_all_lower_letter = boost::algorithm::all(text,boost::algorithm::is_lower());
cout << is_all_lower_letter << endl;
cout << result ;
}