std::transform 转换大小写
#include <algorithm>
#include <iostream>
int main() {
std::string a = "abc";
std::string b = "XYZ";
// 小写转大写,源和目的不同
std::string c;
std::transform(a.begin(), a.end(), std::back_inserter(c), ::toupper);
// 小写转大写,源和目的相同
std::transform(a.begin(), a.end(), a.begin(), ::toupper);
// 大写转小写
std::transform(b.begin(), b.end(), b.begin(), ::tolower);
std::cout << a << std::endl;
std::cout << b << std::endl;
return 0;
}
std::transform 转换大小写
https://leec.me/0991bdb8ae14/