boost::string_algo详解4——trim_if,trim_copy_if,trim_xxxx_if,trim_xxxx_copy_if
来源:互联网 发布:360安全网络漏洞 编辑:程序博客网 时间:2024/06/08 11:24
函数的部分原型
- template<typename SequenceT, typename PredicateT>
- void trim_if(SequenceT & Input, PredicateT IsSpace);
- template<typename OutputIteratorT, typename RangeT, typename PredicateT>
- OutputIteratorT
- trim_copy_if(OutputIteratorT Output, const RangeT & Input,
- PredicateT IsSpace);
- template<typename SequenceT, typename PredicateT>
- SequenceT
- trim_copy_if(const SequenceT & Input, PredicateT IsSpace);
- template<typename SequenceT, typename PredicateT>
- void trim_left_if(SequenceT & Input, PredicateT IsSpace);
- template<typename OutputIteratorT, typename RangeT, typename PredicateT>
- OutputIteratorT
- trim_left_copy_if(OutputIteratorT Output, const RangeT & Input,
- PredicateT IsSpace);
- template<typename SequenceT, typename PredicateT>
- SequenceT
- trim_left_copy_if(const SequenceT & Input, PredicateT IsSpace);
例子
- void test_string_trim_if()
- {
- std::string str = "abcd!@#$%^efghi1234xyz";
- std::string str1 = boost::trim_left_copy_if(str, boost::is_alnum());
- assert(str1 == "!@#$%^efghi1234xyz");
- std::string str2 = boost::trim_right_copy_if(str, boost::is_alnum());
- assert(str2 == "abcd!@#$%^");
- std::string str3 = boost::trim_copy_if(str, boost::is_alnum());
- assert(str3 == "!@#$%^");
- boost::trim_left_if(str, boost::is_alnum());
- assert(str == "!@#$%^efghi1234xyz");
- boost::trim_right_if(str, boost::is_alnum());
- assert(str == "!@#$%^");
- // 如果是二元函数,可以做如下处理
- std::string str2nd("###GoodBye ChongQing!######");
- boost::trim_if(str2nd, bind2nd(std::equal_to<char>(), '#'));
- assert(str2nd == "GoodBye ChongQing!");
- // 当然用下面的方法也可以实现如上的功能
- std::string strAny("###Hello Fuzhou!######");
- boost::trim_if(strAny, boost::is_any_of("#"));
- assert(strAny == "Hello Fuzhou!");
- }
- boost::string_algo详解4——trim_if,trim_copy_if,trim_xxxx_if,trim_xxxx_copy_if
- 【Boost】boost::string_algo详解4——trim_if,trim_copy_if,trim_xxxx_if,trim_xxxx_copy_if
- 【Boost】boost::string_algo详解2——find相关函数
- 【Boost】boost::string_algo详解5——erase相关函数
- 【Boost】boost::string_algo详解6——replace相关函数
- 【Boost】boost::string_algo详解7——join的应用
- boost::string_algo详解5——erase相关函数
- boost::string_algo详解6——replace相关函数
- boost::string_algo详解6——replace相关函数
- boost::string_algo详解7——join的应用
- boost::string_algo详解2——find相关函数
- boost::string_algo详解3——finder的简单应用
- boost::string_algo详解2——find相关函数
- boost::string_algo详解3——finder的简单应用
- boost::string_algo详解1
- boost::string_algo详解1
- 【Boost】boost::string_algo详解1
- 【Boost】boost::string_algo详解3——finder的简单应用
- TCP中的流量控制及拥塞控制
- jQuery liger ui ligerGrid 打造通用的分页排序查询表格(提供下载)
- java问题解答
- drupal7.23 导入中文包出错解决方法
- jQuery LigerUI 使用教程入门篇
- boost::string_algo详解4——trim_if,trim_copy_if,trim_xxxx_if,trim_xxxx_copy_if
- DDX_Control的作用
- 【现在操作系统】第3章 死锁
- [转] 外企面试--基本涵盖了所有问题【附带有答案版本】
- hdu 4570
- android 更多 收起 简单实现
- jQuery LigerUI 使用教程表格篇(1)
- boost::string_algo详解5——erase相关函数
- jQuery插件