void print_element(int value) { cout << value << "\n"; } list<int> a_list; . . . for_each(a_list.begin(), a_list.end(), print_element);