0%

This is my learning notes from the course - Mastering C++ Standard Library Features.

Passing Functions to Functions

  • Higher-order functions
  • Functions as arguments
  • Functions pointers
  • Template parameters
  • std::function
  • function_ref

Higher-Order Functions

Higher-order functions are functions that can either take other functions as arguments or return them as results.

– from Wikipedia - Higher-order function

First-class functions: https://en.wikipedia.org/wiki/First-class_function

Read more »

This is my learning notes from the course - Mastering C++ Standard Library Features.

Storing Callable Objects

  • Storing function objects and closures in variables
  • Interactions between lambdas and function pointers
  • The FunctionObject and Callable concepts
  • std::function: Type erasure for Callable objects

Storing Functions in Variables

1
void foo() { std::cout << "hello!\n"; }
  • Functions can be stored via function pointers
    1
    2
    3
    4
    5
    auto p0 = &foo;
    void(*p1)() = &foo;

    p0(); // prints "hello!"
    p1(); // prints "hello!"
    1
    std::vector<void(*)()> vec{&foo};
    Read more »

This is my learning notes from the course - Mastering C++ Standard Library Features.

Lambdas as First-Class Citizens

  • What it means to be a “first-class citizen
  • How lambdas replace old Standard Library utilities
  • Templates and lambda expressions
  • Type-erasure for lambdas: std::function
  • Higher-order functions

Lambdas: Versatile Tools

  • Meaning of “first-class citizen
  • Standard Library utilities replaced by lambdas
    Read more »