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
efff3765
Commit
efff3765
authored
1 year ago
by
Santiago Ospina De Los Ríos
Committed by
Simon Praetorius
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add explicit function to StaticIntegralRange that returns the std::index_sequience
parent
619440d4
No related branches found
No related tags found
1 merge request
!1339
Add explicit function to StaticIntegralRange that returns the std::index_sequience
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/common/rangeutilities.hh
+3
-0
3 additions, 0 deletions
dune/common/rangeutilities.hh
dune/common/test/rangeutilitiestest.cc
+12
-1
12 additions, 1 deletion
dune/common/test/rangeutilitiestest.cc
with
15 additions
and
1 deletion
dune/common/rangeutilities.hh
+
3
−
0
View file @
efff3765
...
...
@@ -248,6 +248,9 @@ namespace Dune
/** \brief cast into corresponding std::integer_sequence **/
constexpr
operator
integer_sequence
()
const
noexcept
{
return
{};
}
/** \brief return corresponding std::integer_sequence **/
static
constexpr
integer_sequence
to_integer_sequence
()
noexcept
{
return
{};
}
/** \brief obtain a random-access iterator to the first element **/
static
constexpr
iterator
begin
()
noexcept
{
return
iterator
(
from
);
}
/** \brief obtain a random-access iterator past the last element **/
...
...
This diff is collapsed.
Click to expand it.
dune/common/test/rangeutilitiestest.cc
+
12
−
1
View file @
efff3765
...
...
@@ -4,6 +4,7 @@
#include
<array>
#include
<map>
#include
<utility>
#include
<vector>
#include
<numeric>
#include
<type_traits>
...
...
@@ -61,6 +62,10 @@ template<class T>
struct
is_mutable_reference
:
public
std
::
conjunction
<
std
::
is_reference
<
T
>
,
std
::
negation
<
is_const_reference
<
T
>>>
{};
template
<
typename
F
,
typename
T
,
T
...
I
>
void
checkIndexExpansion
(
std
::
integer_sequence
<
T
,
I
...
>
seq
,
F
&&
f
){
f
(
seq
);
}
auto
testTransformedRangeView
()
{
...
...
@@ -305,13 +310,19 @@ int main()
suite
.
check
(
range
(
6
).
contains
(
5
));
suite
.
check
(
not
range
(
6
).
contains
(
6
));
using
StaticRange4
=
decltype
(
range
(
std
::
integral_constant
<
int
,
4
>
()));
auto
range4
=
range
(
std
::
integral_constant
<
int
,
4
>
());
using
StaticRange4
=
decltype
(
range4
);
static_assert
(
StaticRange4
::
contains
(
std
::
integral_constant
<
int
,
3
>
()));
static_assert
(
not
StaticRange4
::
contains
(
4
));
static_assert
(
std
::
is_same
<
StaticRange4
::
integer_sequence
,
std
::
make_integer_sequence
<
int
,
4
>>::
value
,
"decltype(range(std::integral_constant<int, 4>))::integer_sequence must be the same as std::make_integer_sequence<int, 4>"
);
checkIndexExpansion
(
range4
.
to_integer_sequence
(),
[](
auto
seq
){
static_assert
(
std
::
is_same
<
decltype
(
seq
),
std
::
make_integer_sequence
<
int
,
4
>>::
value
,
"decltype(range(std::integral_constant<int, 4>))::integer_sequence must be the same as std::make_integer_sequence<int, 4>"
);
});
// Hybrid::forEach for integer ranges
Dune
::
Hybrid
::
forEach
(
range
(
std
::
integral_constant
<
int
,
1
>
()),
[]
(
auto
&&
i
)
{
static_assert
(
std
::
is_same
<
std
::
decay_t
<
decltype
(
i
)
>
,
std
::
integral_constant
<
int
,
0
>>::
value
,
...
...
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