Process data with C++ standard algorithms and lambdas

8 steps · about 2 h 25 min · Beginner

  1. Survey the algorithms library (article, cppreference, 15 min)

    Shows the toolbox so you reach for it before writing a loop.

  2. Write lambda expressions and captures (article, cppreference, 30 min)

    Needed to pass behaviour into every algorithm.

  3. Sort with a custom comparator (article, cppreference, 15 min)

    First algorithm most programmers need.

  4. Search with find and find_if (article, cppreference, 15 min)

    Replaces linear search loops.

  5. Map values with transform (article, cppreference, 15 min)

    The C++ way to apply a function to a range.

  6. Reduce with accumulate (article, cppreference, 15 min)

    Sums and folds a range.

  7. Erase elements with the erase-remove idiom (article, cppreference, 20 min)

    Avoids a classic bug when deleting from vectors.

  8. Preview ranges in modern C++ (article, cppreference, 20 min)

    Shows composable pipelines that supersede iterator pairs.