#include #include #include using namespace std; template void dumpVec(T c) { cout << "{"; for ( auto el : c ) { cout << el << ", "; } cout << "}" << endl; } void printIf(int val) { if ( val > 100 ) cout << val << ' '; } //---------------------------------------- // This version allows the filter limit // to vary. Problem: How do we pass the // limit value through for_each() to the // printIt routine? //---------------------------------------- int main(int argc, char *argv[]) { vector V = { -1, 40, 101, 12, 0, 0, 102, 4, 8, 103}; cout << "V = "; dumpVec(V); int limit; cout << endl << "Enter limit value: "; cin >> limit; cout << "Filtered[>" << limit << "]: "; for_each(V.begin(), V.end(), printIf); cout << endl; return 0; }