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
73dc8e52
Commit
73dc8e52
authored
6 months ago
by
Simon Praetorius
Committed by
Santiago Ospina De Los Ríos
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Add deduction guides for TupleVector following those of std::tuple
parent
65585764
No related branches found
No related tags found
2 merge requests
!1470
Fix wrong variable name to make target hash (2.10)
,
!1435
Add deduction guides for TupleVector following those of std::tuple
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+4
-0
4 additions, 0 deletions
CHANGELOG.md
dune/common/test/hybridutilitiestest.cc
+28
-0
28 additions, 0 deletions
dune/common/test/hybridutilitiestest.cc
dune/common/tuplevector.hh
+24
-8
24 additions, 8 deletions
dune/common/tuplevector.hh
with
56 additions
and
8 deletions
CHANGELOG.md
+
4
−
0
View file @
73dc8e52
...
...
@@ -5,6 +5,10 @@ SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# Master (will become release 2.11)
## C++: Changelog
-
Add deduction guides to
`TupleVector`
analogous to
`std::tuple`
.
# Release 2.10
## Dependencies
...
...
This diff is collapsed.
Click to expand it.
dune/common/test/hybridutilitiestest.cc
+
28
−
0
View file @
73dc8e52
...
...
@@ -261,5 +261,33 @@ int main()
constexpr
auto
numberTupleConstexpr
=
Dune
::
makeTupleVector
(
0.25
,
2
,
3
);
static_assert
(
sum
(
numberTupleConstexpr
)
==
5.25
,
"Wrong compile time sum!"
);
{
// CTAD tests
auto
tv0
=
Dune
::
TupleVector
{};
// test construction with values
static_assert
(
std
::
is_same_v
<
decltype
(
tv0
),
Dune
::
TupleVector
<>>
);
auto
tv1
=
Dune
::
TupleVector
{
1
,
2.0
,
3.0
f
,
4u
};
static_assert
(
std
::
is_same_v
<
decltype
(
tv1
),
Dune
::
TupleVector
<
int
,
double
,
float
,
unsigned
int
>>
);
auto
tv2
=
Dune
::
TupleVector
{
std
::
tuple
{
1
,
2.0
,
3.0
f
,
4u
}};
static_assert
(
std
::
is_same_v
<
decltype
(
tv2
),
Dune
::
TupleVector
<
int
,
double
,
float
,
unsigned
int
>>
);
auto
tv3
=
Dune
::
TupleVector
{
std
::
pair
{
1
,
2.0
}};
static_assert
(
std
::
is_same_v
<
decltype
(
tv3
),
Dune
::
TupleVector
<
int
,
double
>>
);
// test construction with l-values
Dune
::
FieldVector
<
double
,
2
>
arg1
{};
std
::
vector
<
float
>
arg2
{};
auto
tv4
=
Dune
::
TupleVector
{
arg1
,
arg2
};
static_assert
(
std
::
is_same_v
<
decltype
(
tv4
),
Dune
::
TupleVector
<
Dune
::
FieldVector
<
double
,
2
>
,
std
::
vector
<
float
>>>
);
// test construction with allocators
auto
tv5
=
Dune
::
TupleVector
{
std
::
allocator_arg_t
{},
std
::
allocator
<
float
>
{},
arg1
,
arg2
};
static_assert
(
std
::
is_same_v
<
decltype
(
tv4
),
decltype
(
tv5
)
>
);
auto
tv6
=
Dune
::
TupleVector
{
std
::
allocator_arg_t
{},
std
::
allocator
<
float
>
{},
std
::
tuple
{
arg1
,
arg2
}};
static_assert
(
std
::
is_same_v
<
decltype
(
tv4
),
decltype
(
tv6
)
>
);
auto
tv7
=
Dune
::
TupleVector
{
std
::
allocator_arg_t
{},
std
::
allocator
<
float
>
{},
std
::
pair
{
arg1
,
arg2
}};
static_assert
(
std
::
is_same_v
<
decltype
(
tv4
),
decltype
(
tv7
)
>
);
}
return
test
.
exit
();
}
This diff is collapsed.
Click to expand it.
dune/common/tuplevector.hh
+
24
−
8
View file @
73dc8e52
...
...
@@ -35,13 +35,6 @@ class TupleVector : public std::tuple<T...>
{
using
Base
=
std
::
tuple
<
T
...
>
;
template
<
class
...
TT
>
using
TupleConstructorDetector
=
decltype
(
Base
(
std
::
declval
<
TT
&&>
()...));
template
<
class
...
TT
>
using
hasTupleConstructor
=
Dune
::
Std
::
is_detected
<
TupleConstructorDetector
,
TT
...
>
;
public:
/** \brief Construct from a set of arguments
...
...
@@ -51,7 +44,7 @@ public:
* list.
*/
template
<
class
...
TT
,
std
::
enable_if_t
<
hasTupleConstructor
<
TT
...>
::
value
,
int
>
=
0
>
class
=
std
::
void_t
<
decltype
(
Base
(
std
::
declval
<
TT
&&
>()...))
>
>
constexpr
TupleVector
(
TT
&&
...
tt
)
:
Base
(
std
::
forward
<
TT
>
(
tt
)...)
{}
...
...
@@ -86,6 +79,29 @@ public:
}
};
/// \name Deduction guides for TupleVector
/// \relates TupleVector
/// @{
template
<
class
...
T
>
TupleVector
(
T
...)
->
TupleVector
<
T
...
>
;
template
<
class
T1
,
class
T2
>
TupleVector
(
std
::
pair
<
T1
,
T2
>
)
->
TupleVector
<
T1
,
T2
>
;
template
<
class
...
T
>
TupleVector
(
std
::
tuple
<
T
...
>
)
->
TupleVector
<
T
...
>
;
template
<
class
Alloc
,
class
...
T
>
TupleVector
(
std
::
allocator_arg_t
,
Alloc
,
T
...)
->
TupleVector
<
T
...
>
;
template
<
class
Alloc
,
class
T1
,
class
T2
>
TupleVector
(
std
::
allocator_arg_t
,
Alloc
,
std
::
pair
<
T1
,
T2
>
)
->
TupleVector
<
T1
,
T2
>
;
template
<
class
Alloc
,
class
...
T
>
TupleVector
(
std
::
allocator_arg_t
,
Alloc
,
std
::
tuple
<
T
...
>
)
->
TupleVector
<
T
...
>
;
/// @}
template
<
class
...
T
>
...
...
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