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
af2ad4ec
Commit
af2ad4ec
authored
6 months ago
by
Santiago Ospina De Los Ríos
Committed by
Simon Praetorius
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Use Hybrid::equal_to instead of Hybrid::equals
parent
3fd176b8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1470
Fix wrong variable name to make target hash (2.10)
,
!1410
Use Hybrid::equal_to instead of Hybrid::equals
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-2
2 additions, 2 deletions
CHANGELOG.md
dune/common/hybridutilities.hh
+20
-4
20 additions, 4 deletions
dune/common/hybridutilities.hh
dune/common/test/hybridutilitiestest.cc
+13
-13
13 additions, 13 deletions
dune/common/test/hybridutilitiestest.cc
with
35 additions
and
19 deletions
CHANGELOG.md
+
2
−
2
View file @
af2ad4ec
...
...
@@ -17,7 +17,7 @@ In order to build the DUNE core modules you need at least the following software
-
Python: Add
`TupleVector`
Python bindings
-
Python: The function
`cppType`
now support Python tuples, which are converted to the C++ type
`std::tuple`
-
Python: The function
`cppType`
now support Python tuples, which are converted to the C++ type
`std::tuple`
-
`TupleVector`
now implements the standard protocol for tuple-like types.
...
...
@@ -59,7 +59,7 @@ In order to build the DUNE core modules you need at least the following software
-
Add user-defined literals
`_ic`
,
`_uc`
and
`_sc`
to represent integral constants.
-
Add "hybrid" functors for basic math operations with integral constant arguments, i.e.,
`Hybrid::max`
,
`Hybrid::min`
,
`Hybrid::plus`
,
`Hybrid::minus`
, and
`Hybrid::equal
s
`
. Operations
`Hybrid::max`
,
`Hybrid::min`
,
`Hybrid::plus`
,
`Hybrid::minus`
, and
`Hybrid::equal
_to
`
. Operations
between two integral constants result in an integral constant, whereas operations with at least
one non integral constant argument is performed on the underlying value type.
...
...
This diff is collapsed.
Click to expand it.
dune/common/hybridutilities.hh
+
20
−
4
View file @
af2ad4ec
...
...
@@ -562,14 +562,30 @@ inline constexpr auto minus = hybridFunctor(std::minus<>{});
* \code{.cpp}
* using namespace Dune::Indices;
* { // hybrid transformation!
* auto j = Dune::Hybrid::equal
s
( 2, 1); // -> false
* auto j = Dune::Hybrid::equal
s
( 2, _1); // -> false
* auto k = Dune::Hybrid::equal
s
(_2, _1); // -> std::false_type
* auto j = Dune::Hybrid::equal
_to
( 2, 1); // -> false
* auto j = Dune::Hybrid::equal
_to
( 2, _1); // -> false
* auto k = Dune::Hybrid::equal
_to
(_2, _1); // -> std::false_type
* // independent of the context, `k` encodes its value in the type system
* }
* \endcode
*/
inline
constexpr
auto
equals
=
hybridFunctor
(
std
::
equal_to
<>
{});
inline
constexpr
auto
equal_to
=
hybridFunctor
(
std
::
equal_to
<>
{});
/**
* \brief Equality comparison
*
* \ingroup HybridUtilities
*
* If both types have a static member value, the result of comparing
* these is returned as std::integral_constant<bool, *>. Otherwise
* the result of a runtime comparison of t1 and t2 is directly returned.
*/
template
<
class
T1
,
class
T2
>
constexpr
auto
equals
(
T1
&&
t1
,
T2
&&
t2
){
return
equal_to
(
std
::
forward
<
T1
>
(
t1
),
std
::
forward
<
T2
>
(
t2
));
}
namespace
Impl
{
...
...
This diff is collapsed.
Click to expand it.
dune/common/test/hybridutilitiestest.cc
+
13
−
13
View file @
af2ad4ec
...
...
@@ -36,7 +36,7 @@ auto incAndAppendToFirst(C&& c)
forEach
(
integralRange
(
Dune
::
Hybrid
::
size
(
c
)),
[
&
](
auto
&&
i
)
{
using
namespace
Dune
::
Hybrid
;
using
namespace
Dune
::
Indices
;
ifElse
(
equal
s
(
i
,
_0
),
[
&
](
auto
id
)
{
ifElse
(
equal
_to
(
i
,
_0
),
[
&
](
auto
id
)
{
id
(
c
[
i
]).
append
(
"+1"
);
},
[
&
](
auto
id
)
{
++
id
(
c
[
i
]);
...
...
@@ -174,26 +174,26 @@ int main()
Dune
::
TestSuite
test
;
using
namespace
Dune
::
Indices
;
static_assert
(
Dune
::
Hybrid
::
equal
s
(
_1
,
_1
));
static_assert
(
not
Dune
::
Hybrid
::
equal
s
(
_1
,
_2
));
static_assert
(
Dune
::
Hybrid
::
equal
_to
(
_1
,
_1
));
static_assert
(
not
Dune
::
Hybrid
::
equal
_to
(
_1
,
_2
));
static_assert
(
Dune
::
Hybrid
::
equal
s
(
1
,
_1
));
test
.
check
(
Dune
::
Hybrid
::
equal
s
(
one
,
one
))
<<
"Runtime Hybrid::equal
s
failed."
;
static_assert
(
Dune
::
Hybrid
::
equal
_to
(
1
,
_1
));
test
.
check
(
Dune
::
Hybrid
::
equal
_to
(
one
,
one
))
<<
"Runtime Hybrid::equal
_to
failed."
;
static_assert
(
Dune
::
Hybrid
::
equal
s
(
_3
,
Dune
::
Hybrid
::
max
(
_1
,
_2
,
_3
)));
test
.
check
(
Dune
::
Hybrid
::
equal
s
(
3
,
Dune
::
Hybrid
::
max
(
one
,
_2
,
_3
)))
static_assert
(
Dune
::
Hybrid
::
equal
_to
(
_3
,
Dune
::
Hybrid
::
max
(
_1
,
_2
,
_3
)));
test
.
check
(
Dune
::
Hybrid
::
equal
_to
(
3
,
Dune
::
Hybrid
::
max
(
one
,
_2
,
_3
)))
<<
"Runtime Hybrid::max failed."
;
static_assert
(
Dune
::
Hybrid
::
equal
s
(
_1
,
Dune
::
Hybrid
::
min
(
_1
,
_2
,
_3
)));
test
.
check
(
Dune
::
Hybrid
::
equal
s
(
one
,
Dune
::
Hybrid
::
min
(
one
,
_2
,
_3
)))
static_assert
(
Dune
::
Hybrid
::
equal
_to
(
_1
,
Dune
::
Hybrid
::
min
(
_1
,
_2
,
_3
)));
test
.
check
(
Dune
::
Hybrid
::
equal
_to
(
one
,
Dune
::
Hybrid
::
min
(
one
,
_2
,
_3
)))
<<
"Runtime Hybrid::min failed."
;
static_assert
(
Dune
::
Hybrid
::
equal
s
(
_4
,
Dune
::
Hybrid
::
plus
(
_1
,
_3
)));
test
.
check
(
Dune
::
Hybrid
::
equal
s
(
4
,
Dune
::
Hybrid
::
plus
(
one
,
_3
)))
static_assert
(
Dune
::
Hybrid
::
equal
_to
(
_4
,
Dune
::
Hybrid
::
plus
(
_1
,
_3
)));
test
.
check
(
Dune
::
Hybrid
::
equal
_to
(
4
,
Dune
::
Hybrid
::
plus
(
one
,
_3
)))
<<
"Runtime Hybrid::plus failed."
;
static_assert
(
Dune
::
Hybrid
::
equal
s
(
_2
,
Dune
::
Hybrid
::
minus
(
_3
,
_1
)));
test
.
check
(
Dune
::
Hybrid
::
equal
s
(
2
,
Dune
::
Hybrid
::
minus
(
_3
,
one
)))
static_assert
(
Dune
::
Hybrid
::
equal
_to
(
_2
,
Dune
::
Hybrid
::
minus
(
_3
,
_1
)));
test
.
check
(
Dune
::
Hybrid
::
equal
_to
(
2
,
Dune
::
Hybrid
::
minus
(
_3
,
one
)))
<<
"Runtime Hybrid::minus failed."
;
incrementAll
(
vector
);
...
...
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