【Boost】boost::to_upper_copy介绍
发布时间:2021-11-22 10:13:45 所属栏目:教程 来源:互联网
导读:boost::to_upper_copy有两种构造函数,特别是第二种,注意boost::range的使用。 函数形式: templatetypename OutputIteratorT, typename RangeT OutputIteratorT to_upper_copy(OutputIteratorT Output, const RangeT Input, const std::locale Loc = std::l
boost::to_upper_copy有两种构造函数,特别是第二种,注意boost::range的使用。 函数形式: template<typename OutputIteratorT, typename RangeT> OutputIteratorT to_upper_copy(OutputIteratorT Output, const RangeT & Input, const std::locale & Loc = std::locale()); template<typename SequenceT> SequenceT to_upper_copy(const SequenceT & Input, const std::locale & Loc = std::locale()); 例子: // to_upper_copy两种重载函数 void test_string_upper() { std::string str1 = "Hello world!"; // 方法1 std::string str2 = boost::to_upper_copy(str1); assert(str2 == "HELLO WORLD!"); // 方法2, 第二个参数是range, 可以是如下几种类型 // 1. make_pire(iterator, iterator) // 2. std::string // 3. 数组 std::string str3 = "str3 = "; boost::to_upper_copy(std::back_inserter(str3), std::make_pair(str1.begin(), str1.end())); assert(str3 == "str3 = HELLO WORLD!"); std::string str4 = "str4 = "; boost::to_upper_copy(std::back_inserter(str4), "HELLO WORLD!"); assert(str4 == "str4 = HELLO WORLD!"); std::string str5 = "str5 = "; boost::to_upper_copy(std::back_inserter(str5), boost::make_iterator_range(str1)); assert(str5 == "str5 = HELLO WORLD!"); std::string str6 = "str6 = "; char* p = "HELLO WORLD!"; boost::to_upper_copy(std::back_inserter(str6), p); assert(str6 == "str6 = HELLO WORLD!"); } ![]() (编辑:开发网_开封站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |