forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmixed-function-expression-with-pointer-capture.cpp
More file actions
44 lines (28 loc) · 1.35 KB
/
Copy pathmixed-function-expression-with-pointer-capture.cpp
File metadata and controls
44 lines (28 loc) · 1.35 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <vector>
#include <ranges>
#include <string>
#include <span>
#include <algorithm>
#include <iostream>
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
#line 1 "regression-tests/mixed-function-expression-with-pointer-capture.cpp2"
//=== Cpp2 type definitions and function declarations ===========================
#line 1 "regression-tests/mixed-function-expression-with-pointer-capture.cpp2"
#line 8 "regression-tests/mixed-function-expression-with-pointer-capture.cpp2"
[[nodiscard]] auto main() -> int;
//=== Cpp2 function definitions =================================================
#line 1 "regression-tests/mixed-function-expression-with-pointer-capture.cpp2"
#line 8 "regression-tests/mixed-function-expression-with-pointer-capture.cpp2"
[[nodiscard]] auto main() -> int{
std::vector<std::string> vec {
"hello", "2023"};
std::string y {"\n"};
std::ranges::for_each(vec, [_0 = (&y)](auto const& x) mutable -> decltype(auto) {
return std::cout << CPP2_UFCS(c_str)((*cpp2::impl::assert_not_null(_0))) << x << *cpp2::impl::assert_not_null(_0); }
);
auto callback {[](auto& x) -> decltype(auto) { return x += "-ish"; }};
std::ranges::for_each(vec, cpp2::move(callback));
for ( auto const& str : cpp2::move(vec) )
std::cout << str << "\n";
}