#include #include #include #include #include #include /** TESTCASES **/ /* Expected output: 1 2 3 1 2 one two (1, one) (2, two) one three two */ void print(int key, std::string const& value) { std::cout << "(" << key << ", " << value << ") "; } struct IntPrinter { void operator()(int key) const { std::cout << key << " "; }; }; int main() { std::vector v { 1, 2, 3 }; iterate(v.begin(), v.end(), [](int v) { std::cout << v << " "; }); std::cout << std::endl; std::list> l { { 1, "one" }, { 2, "two" } }; iterate(l.begin(), l.end(), IntPrinter{}); std::cout << std::endl; iterate(l.begin(), l.end(), [](std::string const& v) { std::cout << v << " "; }); std::cout << std::endl; iterate(l.begin(), l.end(), print); std::cout << std::endl; std::map m { { "one", "1" }, { "two", "2" }, { "three", "3" } }; iterate(m.begin(), m.end(), [](std::string const& k) { std::cout << k << " "; }); std::cout << std::endl; }