transform(temp.begin(),temp.end(),temp.begin(),toupper)

transform(temp.begin(),temp.end(),temp.begin(),toupper);

 std::string sl = "hello";

transform(sl.begin(), sl.end(), sl.begin(), (int(*)(int))std::toupper);

这样得到 sl 值是 大写的 HELLO
transform 是遍历一个容器里面元素 然后执行一个操作
第1和2个参数是数据起始和结束位置(迭代器)
参数3是写入目标的起始位置
参数4是执行的操作(函数)
posted @ 2011-02-12 17:10  BloodAndBone  Views(502)  Comments(0Edit  收藏  举报