Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <iterator>
- template <class T>
- void print(const T& v) {
- std::copy(v.begin(), v.end(),
- std::ostream_iterator<typename T::value_type>(std::cout, "n"));
- }
- std::string lowercase(const std::string& s)
- {
- std::string result(s);
- std::transform(result.begin(), result.end(), result.begin(), ::tolower);
- return result;
- }
- int main() {
- std::vector<std::string> tokens {"Col1", "Col2", "File", "FileIn.dat", "Out", "FileOut.dat"};
- std::transform(tokens.begin(), tokens.end(), tokens.begin(), lowercase);
- // how to replace lowercase() with a lambda that will take the previous
- // element into account while converting an element into lowercase
- print(tokens);
- return 0;
- }
- {"col1", "col2", "file", "FileIn.dat", "out", "FileOut.dat"};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement