// C++11 - Fonction lambda #include #include using namespace std; int main() { int arr[] = { 2, 4, 6, 7, 8, 9 }; // Le 3e argument de for_each est une fonction lambda : for_each(begin(arr), end(arr), [](int n) { cout << n << endl; }); cout << '\n'; // Le type auto est bien pratique pour une fonction lambda : auto is_odd = [](int n) { return n%2 == 1; }; auto pos = find_if(begin(arr), end(arr), is_odd); if(pos != end(arr)) cout << *pos << endl; return 0; } // main()