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 tobooland 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>::referenceInstead 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 notboolorchartypes.Possibility to constrain integer return types, e.g., ofsize()methods
-
Hashable: a type that can be hashed usingstd::hashutility and thus can be used in hash maps directly.- Can be used in the concept definition of an IdType in IdSets
-
ContainerandRandomAccessContainer: types following the stl definition of containers.RandomAccesshere 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::arrayorstd::vectororReservedVectoror... - Example: The definition of
IndexSet::Typesin 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