随笔 - C++ 中的 std::transform 用法 (C++11)
简要记录 std::transform
的用法
声明
作用
对 [__first,__last)
内的元素应用 __unary_op
, 并将结果储存在以 __result
开头的区域内
对 [__first1,__last1)
和 [__first2,__first2+__last1-__first1)
内的元素应用 __binary_op
, 并将结果储存在以 __result
开头的区域内
Tips
以下程序和示例程序等价
1 |
|
此处要注意一点,因为 using namespace std;
, 致使 <cctype>
中的 toupper
和 <locale>
中的 std::toupper
发生混淆,此时需要加 ::
限定作用域