template void for_each(const Type& container, std::function &funct) { for (auto&& elem : container) { funct(elem); } } int main() { vector v = { 1, 2, 3 }; for_each(v, [](int e){ cout << e << endl; }); for_each(vector({ 1, 2, 3 }), [](int e){ cout << e << endl; }); function funct = [](int e) { cout << e << endl; }; for_each(v, funct); for_each(vector{1}, funct); return 0; }