FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
learnmoderncpp-tutorial/modules/07-span.cpp at main · cpp-tutor/learnmoderncpp-tutorial · GitHub
cpp-tutor
/
learnmoderncpp-tutorial
Public
Notifications
You must be signed in to change notification settings
Fork
24
Star
167
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
learnmoderncpp-tutorial
/
modules
/
07-span.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (19 loc) · 520 Bytes
Breadcrumbs
learnmoderncpp-tutorial
/
modules
/
07-span.cpp
Copy path
File metadata and controls
23 lines (19 loc) · 520 Bytes
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
//
07-span.cpp : convert different container types to span and print them out
import
std;
using
namespace
std
;
void
print_ints
(span<
int
> s) {
for
(
auto
sep{
"
"
sv };
auto
& e : s) {
cout << sep << e;
sep =
"
,
"
sv;
}
cout <<
'
\n
'
;
}
int
main
() {
int
c_array[] = {
1
,
2
,
3
};
vector vec = {
2
,
6
,
4
,
3
};
array<
int
,
4
> std_array = {
7
,
6
,
5
};
print_ints
(c_array);
print_ints
(vec);
print_ints
(std_array);
//
print_ints({ 9, 8, 7, 6 }); // Error: does not compile
}
Back
|
FazBrowse Home
|
New Git URL