summaryrefslogtreecommitdiffhomepage
path: root/CompilerDriver/cc2/regression-tests/mixed-function-expression-and-std-for-each.cpp2
blob: 4f0c47f11dd1575e92bf392f4af27ceef8f90c6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <vector>
#include <string>
#include <span>
#include <algorithm>
#include <iostream>

main: () -> int = {
    vec: std::vector<std::string>
            = ("hello", "2022");

    //  Passing a function expression
    std::ranges::for_each(
        vec,
        :(inout x) = x += "-ish"
    );

    //  Initializing from a function expression
    callback := :(inout x) = x += " maybe";
    std::ranges::for_each(
        vec,
        callback
    );

    for vec do (str) {
        std::cout << str << "\n";
    }
}