Skip to content
Snippets Groups Projects
Commit a84032ad authored by Steffen Müthing's avatar Steffen Müthing
Browse files

[referenceelements] Make reference element comparable and hashable

The identity of a reference element is for now based around the notion
that the implementation is a singleton, so comparisons are based on
the stored pointer value.
parent 9c50bb77
No related branches found
No related tags found
1 merge request!52Rework ReferenceElement interface
......@@ -236,6 +236,25 @@ namespace Dune {
#endif // DOXYGEN
//! Compares for equality with another reference element.
bool operator==(const ReferenceElement& r) const
{
return _impl == r._impl;
}
//! Compares for inequality with another reference element.
bool operator!=(const ReferenceElement& r) const
{
return not (*this == r);
}
//! Yields a hash value suitable for storing the reference element a in hash table
friend std::size_t hash_value(const ReferenceElement& r)
{
return reinterpret_cast<std::size_t>(r._impl);
}
private:
// The implementation must be a friend to construct a wrapper around itself.
......
......@@ -34,6 +34,15 @@ int main () try
type.makeLine();
{
// check default constructibility and comparison operators
ReferenceElements<double,1>::ReferenceElement r1, r2;
test(r1 == r2);
test(not (r1 != r2));
// check hash value
testcmp(hash_value(r1),0);
}
const ReferenceElement<double,1>& referenceLine = ReferenceElements<double, 1>::general(type);
// size(int c)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment