Skip to content

Lambda in C++

C++ auto f = [](){…}

Flowchart (ISO 5807)

Startr = square(5)EndFigure 1 — demoStartInput xReturn x²EndFigure 2 — square

Source code

C++
void demo() {
    auto square = [](int x) {
        return x * x;
    };
    int r = square(5);
}

The editor opens with this code — change it and the chart redraws.

Language
C++
Constructs
auto f = [](){…}
Topic
Lambdas
Formats
Word, Visio, draw.io, PDF, SVG

Related examples