Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
3fec45ce
Commit
3fec45ce
authored
May 03, 2019
by
Praetorius, Simon
Browse files
Merge branch 'feature/apply_for_variadic' into 'master'
extend apply and for_each functions See merge request
!43
parents
51fa4226
823cb0e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/amdis/common/Apply.hpp
View file @
3fec45ce
...
...
@@ -41,6 +41,13 @@ namespace AMDiS
return
apply
(
FWD
(
f
),
std
::
forward_as_tuple
(
args
...));
}
template
<
std
::
size_t
N
,
class
Functor
>
constexpr
decltype
(
auto
)
apply_indices
(
Functor
&&
f
)
{
return
Impl_
::
apply_indices_impl
(
FWD
(
f
),
index_t
<
0
>
{},
std
::
make_index_sequence
<
N
>
{});
}
template
<
class
Functor
,
std
::
size_t
N
>
constexpr
decltype
(
auto
)
apply_indices
(
Functor
&&
f
,
index_t
<
N
>
)
{
...
...
src/amdis/common/ForEach.hpp
View file @
3fec45ce
...
...
@@ -15,6 +15,16 @@ namespace AMDiS
void
ignored_evaluation
(
std
::
initializer_list
<
T
>&&
)
{
/* do nothing */
}
}
template
<
class
Functor
,
class
...
Args
>
constexpr
void
for_variadic
(
Functor
&&
f
,
Args
&&
...
args
)
{
#if AMDIS_HAS_CXX_FOLD_EXPRESSIONS
(
f
(
FWD
(
args
)),...);
#else
Impl_
::
ignored_evaluation
<
int
>
({
0
,
(
f
(
FWD
(
args
)),
0
)...});
#endif
}
template
<
std
::
size_t
...
I
,
class
Tuple
,
class
Functor
>
constexpr
void
for_each
(
std
::
index_sequence
<
I
...
>
,
Tuple
&&
tuple
,
Functor
&&
f
)
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment