鉴于string foo
,我已经写了关于如何使用's将字符转换为小写的答案cctype
tolower
transform(cbegin(foo), cend(foo), begin(foo), static_cast<int (*)(int)>(tolower))
但我已经开始考虑 locale
's tolower
,可以这样使用:
use_facet<ctype<char>>(cout.getloc()).tolower(data(foo), next(data(foo), foo.size()));
- 是否有理由更喜欢其中一个而不是另一个?
- 它们的功能有什么不同吗?
- 我的意思是除了
tolower
接受并返回int
我认为只是一些过时的 C 东西的事实吗?