diff options
Diffstat (limited to 'CompilerDriver/cc2/regression-tests/mixed-function-expression-and-std-for-each.cpp2')
| -rw-r--r-- | CompilerDriver/cc2/regression-tests/mixed-function-expression-and-std-for-each.cpp2 | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/CompilerDriver/cc2/regression-tests/mixed-function-expression-and-std-for-each.cpp2 b/CompilerDriver/cc2/regression-tests/mixed-function-expression-and-std-for-each.cpp2 new file mode 100644 index 0000000..4f0c47f --- /dev/null +++ b/CompilerDriver/cc2/regression-tests/mixed-function-expression-and-std-for-each.cpp2 @@ -0,0 +1,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"; + } +} |
