Given string foo
, I've written answers on how to use cctype
's tolower
to convert the characters to lowercase
transform(cbegin(foo), cend(foo), begin(foo), static_cast<int (*)(int)>(tolower))
But I've begun to consider locale
's tolower
, which could be used like this:
use_facet<ctype<char>>(cout.getloc()).tolower(data(foo), next(data(foo), foo.size()));
- Is there a reason to prefer one of these over the other?
- Does their functionality differ at all?
- I mean other than the fact that
tolower
accepts and returns an int
which I assume is just some antiquated C stuff?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…