Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ag-ohlberger
dune-community
dune-xt
Commits
a11c842c
Commit
a11c842c
authored
5 years ago
by
Tobias Leibner
Browse files
Options
Downloads
Patches
Plain Diff
[common.numeric] use perfect forwarding
parent
77ca412b
No related branches found
No related tags found
1 merge request
!9
Fix reduce
Pipeline
#57547
canceled
5 years ago
Stage: test
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/xt/common/numeric.hh
+8
-28
8 additions, 28 deletions
dune/xt/common/numeric.hh
with
8 additions
and
28 deletions
dune/xt/common/numeric.hh
+
8
−
28
View file @
a11c842c
...
@@ -25,43 +25,23 @@ namespace XT {
...
@@ -25,43 +25,23 @@ namespace XT {
namespace
Common
{
namespace
Common
{
template
<
class
InputIt
,
class
T
>
template
<
class
...
Args
>
T
reduce
(
InputIt
first
,
InputIt
last
,
T
init
)
decltype
(
auto
)
reduce
(
Args
&&
...
args
)
{
{
#if CPP17_PARALLELISM_TS_SUPPORTED
#if CPP17_PARALLELISM_TS_SUPPORTED
return
std
::
reduce
(
first
,
last
,
init
);
return
std
::
reduce
(
std
::
forward
<
Args
>
(
args
)...
);
#else
#else
return
std
::
accumulate
(
first
,
last
,
init
);
return
std
::
accumulate
(
std
::
forward
<
Args
>
(
args
)...
);
#endif
#endif
}
}
template
<
class
InputIt
,
class
T
,
class
BinaryOp
>
template
<
class
...
Args
>
T
reduce
(
InputIt
first
,
InputIt
last
,
T
init
,
BinaryOp
binary_op
)
decltype
(
auto
)
transform_reduce
(
Args
&&
...
args
)
{
{
#if CPP17_PARALLELISM_TS_SUPPORTED
#if CPP17_PARALLELISM_TS_SUPPORTED
return
std
::
reduce
(
first
,
last
,
init
,
binary_op
);
return
std
::
transform_reduce
(
std
::
forward
<
Args
>
(
args
)...
);
#else
#else
return
std
::
accumulate
(
first
,
last
,
init
,
binary_op
);
return
std
::
inner_product
(
std
::
forward
<
Args
>
(
args
)...);
#endif
}
template
<
class
InputIt1
,
class
InputIt2
,
class
T
>
T
transform_reduce
(
InputIt1
first1
,
InputIt1
last1
,
InputIt2
first2
,
T
init
)
{
#if CPP17_PARALLELISM_TS_SUPPORTED
return
std
::
transform_reduce
(
first1
,
last1
,
first2
,
init
);
#else
return
std
::
inner_product
(
first1
,
last1
,
first2
,
init
);
#endif
}
template
<
class
InputIt1
,
class
InputIt2
,
class
T
,
class
BinaryOp1
,
class
BinaryOp2
>
T
transform_reduce
(
InputIt1
first1
,
InputIt1
last1
,
InputIt2
first2
,
T
init
,
BinaryOp1
binary_op1
,
BinaryOp2
binary_op2
)
{
#if CPP17_PARALLELISM_TS_SUPPORTED
return
std
::
transform_reduce
(
first1
,
last1
,
first2
,
init
,
binary_op1
,
binary_op2
);
#else
return
std
::
inner_product
(
first1
,
last1
,
first2
,
init
,
binary_op1
,
binary_op2
);
#endif
#endif
}
}
...
...
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