Add a collection of useful concept definitions
Summary
In this MR some c++20 concepts are added to the dune-common module to be used in downstream modules if C++20 compiler is available. These concepts are not provided by the c++ standard library but useful, e.g., in the definition of concepts for dune-grid. All concepts are tested for types from c++ standard library but also from the dune-common module.
Concepts
-
BooleanTestable
: anything that can be converted tobool
and allows negation which also is convertible tobool
. Thus, these types can be used in if-then-else conditions. Examples includebool
,int
,int*
,std::vector<bool>::reference
Instead of requiring that a method likeempty()
returns exactlybool
, it can be anything behaving like a boolean.
-
Integer
: a restriction of integral types to those that are notbool
orchar
types.Possibility to constrain integer return types, e.g., ofsize()
methods
-
Hashable
: a type that can be hashed usingstd::hash
utility and thus can be used in hash maps directly.- Can be used in the concept definition of an IdType in IdSets
-
Container
andRandomAccessContainer
: types following the stl definition of containers.RandomAccess
here means that the iterators are random-access iterators and that we have anoperator[]
in the container.- Can be used in multiple places where generic containers are required, but it doesn't matter whether it is a
std::array
orstd::vector
orReservedVector
or... - Example: The definition of
IndexSet::Types
in the dune-grid interface
- Can be used in multiple places where generic containers are required, but it doesn't matter whether it is a
TODO
-
Add documentation of the concepts -
Add changelog entry
Edited by Simon Praetorius