FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppfront/mixed-function-expression-and-std-for-each.cpp at main · jnorthrup/cppfront · GitHub
jnorthrup
/
cppfront
Public
forked from
hsutter/cppfront
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
8
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppfront
/
mixed-function-expression-and-std-for-each.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (33 loc) · 1.3 KB
Breadcrumbs
cppfront
/
mixed-function-expression-and-std-for-each.cpp
Copy path
File metadata and controls
49 lines (33 loc) · 1.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
44
45
46
47
48
#
include
<
vector
>
#
include
<
string
>
#
include
<
span
>
#
include
<
algorithm
>
#
include
<
iostream
>
//
=== Cpp2 type declarations ====================================================
#
include
"
cpp2util.h
"
#
line
1 "regression-tests/mixed-function-expression-and-std-for-each.cpp2"
//
=== Cpp2 type definitions and function declarations ===========================
#
line
1 "regression-tests/mixed-function-expression-and-std-for-each.cpp2"
#
line
7 "regression-tests/mixed-function-expression-and-std-for-each.cpp2"
[[nodiscard]]
auto
main
() -> int;
//
=== Cpp2 function definitions =================================================
#
line
1 "regression-tests/mixed-function-expression-and-std-for-each.cpp2"
#
line
7 "regression-tests/mixed-function-expression-and-std-for-each.cpp2"
[[nodiscard]]
auto
main
() -> int{
std::vector<std::string> vec {
"
hello
"
,
"
2022
"
};
//
Passing a function expression
std::ranges::for_each
(
vec,
[](
auto
& x) ->
decltype
(
auto
) {
return
x +=
"
-ish
"
; }
);
//
Initializing from a function expression
auto
callback {[](
auto
& x) ->
decltype
(
auto
) {
return
x +=
"
maybe
"
; }};
std::ranges::for_each
(
vec,
cpp2::move
(callback)
);
for
(
auto
const
& str :
cpp2::move
(vec) ) {
std::cout << str <<
"
\n
"
;
}
}
Back
|
FazBrowse Home
|
New Git URL