首页 > 其他 > 详细

transform

时间:2019-02-19 23:06:40      阅读:188      评论:0      收藏:0      [点我收藏+]

  对range内的元素进行某种操作,与for_each类似可搭配function object对range内的元素进行操作,但for_each不关心function object的返回值,但transform会把操作后的range输出到另一个range

  可以被就地来更改序列,允许first和result相等,但outputIterator result不可与first和last中的任何一个inputIterator相同

//版本一:UnaryFunction作用于input range上, 
template <class InputerIterator,class OutputIterator,class UnaryFunction>
OutputIterator transform(InputerIterator first,InputerIterator last,OutputIterator result,UnaryFunction cmp);

//版本二:第一个range对应的i1和第二个range对应的i2,cmp(*i1,*i2)后赋值给result 
template <class InputerIterator1,class InputerIterator2,class OutputIterator,class BinaryFunction>
OutputIterator transform(InputerIterator first1,InputerIterator last1,
                         InputerIterator2 first2,first2OutputIterator result,BinaryFunction cmp);

 

transform

原文:https://www.cnblogs.com/tianzeng/p/10403834.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!