Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Parallel STL course
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michaël El Kharroubi
Parallel STL course
Commits
2d5a024f
Commit
2d5a024f
authored
1 year ago
by
Michaël El Kharroubi
Browse files
Options
Downloads
Patches
Plain Diff
[WIP] Add examples for future C++
parent
6ecd9e3a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
Examples/cartesian_prod.cpp
+23
-0
23 additions, 0 deletions
Examples/cartesian_prod.cpp
Examples/mdspan.cpp
+23
-0
23 additions, 0 deletions
Examples/mdspan.cpp
with
48 additions
and
1 deletion
.gitignore
+
2
−
1
View file @
2d5a024f
PDFs/*.pdf
PDFs/*.pdf
**/Examples/artefacts
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Examples/cartesian_prod.cpp
0 → 100644
+
23
−
0
View file @
2d5a024f
#include
<array>
#include
<iostream>
#include
<list>
#include
<ranges/v3/view/cartesian_product.hpp>
#include
<ranges>
#include
<string>
#include
<vector>
namespace
stdexp
=
std
::
experimental
;
void
print
(
std
::
tuple
<
char
const
&
,
int
const
&
,
std
::
string
const
&>
t
,
int
pos
)
{
const
auto
&
[
a
,
b
,
c
]
=
t
;
std
::
cout
<<
'('
<<
a
<<
' '
<<
b
<<
' '
<<
c
<<
')'
<<
(
pos
%
4
?
" "
:
"
\n
"
);
}
int
main
()
{
const
auto
x
=
std
::
array
{
'A'
,
'B'
};
const
auto
y
=
std
::
vector
{
1
,
2
,
3
};
const
auto
z
=
std
::
list
<
std
::
string
>
{
"α"
,
"β"
,
"γ"
,
"δ"
};
for
(
int
i
{
1
};
auto
const
&
tuple
:
stdexp
::
views
::
cartesian_product
(
x
,
y
,
z
))
print
(
tuple
,
i
++
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Examples/mdspan.cpp
0 → 100644
+
23
−
0
View file @
2d5a024f
#include
<experimental/mdspan>
#include
<iostream>
namespace
stdex
=
std
::
experimental
;
int
main
()
{
std
::
array
d
{
0
,
5
,
1
,
3
,
8
,
4
,
2
,
7
,
6
,
};
stdex
::
mdspan
m
{
d
.
data
(),
stdex
::
extents
{
3
,
3
}};
static_assert
(
m
.
rank
()
==
2
,
"Rank is two"
);
for
(
std
::
size_t
i
=
0
;
i
<
m
.
extent
(
0
);
++
i
)
for
(
std
::
size_t
j
=
0
;
j
<
m
.
extent
(
1
);
++
j
)
std
::
cout
<<
"m("
<<
i
<<
", "
<<
j
<<
") == "
<<
m
(
i
,
j
)
<<
"
\n
"
;
return
0
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment