codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <string> #include <cctype> #include <algorithm> #include <functional> #include <iostream> int main() { //Transform a string in-place std::string s("hello"); std::transform(s.begin(), s.end(), s.begin(), std::ptr_fun<int, int>(std::toupper)); std::cout << s << std::endl; //Transform a string while copying std::string s2; s2.reserve(s.size()); std::transform(s.begin(), s.end(), std::back_inserter(s2), std::ptr_fun<int, int>(std::tolower)); std::cout << s2 << std::endl; }
Private
[
?
]
Run code
Submit