Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Core Modules
dune-common
Commits
5b856431
Commit
5b856431
authored
9 years ago
by
Christian Engwer
Browse files
Options
Downloads
Patches
Plain Diff
[add] helper classes for reduction-type operations on ranges
parent
0d9a417a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!70
Document that tests need to be build before running them and how to do that
,
!16
add support for vectorization library VC
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/common/rangeutilities.hh
+81
-0
81 additions, 0 deletions
dune/common/rangeutilities.hh
with
81 additions
and
0 deletions
dune/common/rangeutilities.hh
0 → 100644
+
81
−
0
View file @
5b856431
#ifndef DUNE_COMMON_RANGE_UTILITIES_HH
#define DUNE_COMMON_RANGE_UTILITIES_HH
#include
<dune/common/typetraits.hh>
#include
<utility>
#include
<type_traits>
#include
<bitset>
namespace
Dune
{
template
<
typename
T
,
typename
std
::
enable_if
<!
is_range
<
T
>
::
value
,
int
>::
type
=
0
>
const
T
&
max_value
(
const
T
&
v
)
{
return
v
;
};
template
<
typename
T
,
typename
std
::
enable_if
<
is_range
<
T
>
::
value
,
int
>::
type
=
0
>
typename
T
::
value_type
max_value
(
const
T
&
v
)
{
using
std
::
max
;
typename
T
::
value_type
m
;
for
(
const
auto
&
e
:
v
)
m
=
max
(
e
,
m
);
return
m
;
};
template
<
typename
T
,
typename
std
::
enable_if
<!
is_range
<
T
>
::
value
,
int
>::
type
=
0
>
T
&
min_value
(
const
T
&
v
)
{
return
v
;
};
template
<
typename
T
,
typename
std
::
enable_if
<
is_range
<
T
>
::
value
,
int
>::
type
=
0
>
typename
T
::
value_type
min_value
(
const
T
&
v
)
{
using
std
::
min
;
typename
T
::
value_type
m
;
for
(
const
auto
&
e
:
v
)
m
=
min
(
e
,
m
);
return
m
;
};
template
<
typename
T
,
typename
std
::
enable_if
<!
is_range
<
T
>
::
value
,
int
>::
type
=
0
>
bool
any_true
(
const
T
&
v
)
{
return
v
;
};
template
<
typename
T
,
typename
std
::
enable_if
<
is_range
<
T
>
::
value
,
int
>::
type
=
0
>
bool
any_true
(
const
T
&
v
)
{
bool
b
=
false
;
for
(
const
auto
&
e
:
v
)
b
=
b
or
bool
(
e
);
return
b
;
};
template
<
std
::
size_t
N
>
bool
any_true
(
const
std
::
bitset
<
N
>
&
b
)
{
return
b
.
any
();
}
template
<
typename
T
,
typename
std
::
enable_if
<!
is_range
<
T
>
::
value
,
int
>::
type
=
0
>
bool
all_true
(
const
T
&
v
)
{
return
v
;
};
template
<
typename
T
,
typename
std
::
enable_if
<
is_range
<
T
>
::
value
,
int
>::
type
=
0
>
bool
all_true
(
const
T
&
v
)
{
bool
b
=
true
;
for
(
const
auto
&
e
:
v
)
b
=
b
and
bool
(
e
);
return
b
;
};
template
<
std
::
size_t
N
>
bool
all_true
(
const
std
::
bitset
<
N
>
&
b
)
{
return
b
.
all
();
}
}
#endif // DUNE_COMMON_RANGE_UTILITIES_HH
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