![]() |
Cytopia
0.3
A city building simulation game
|
Allows Type to be hashable, use operator==, and use operator!=. More...
#include <IEquatable.hxx>
Public Member Functions | |
IEquatable () | |
Create an Equatable type. More... | |
constexpr bool | operator!= (const IEquatable< Type > &other) const noexcept |
bool | operator== (const IEquatable< Type > &other) const noexcept |
Protected Member Functions | |
void | onHashChanged (std::size_t hash) noexcept |
Call when the hash has changed. More... | |
void | onHashChanged () noexcept |
Call when the hash has changed. More... | |
Private Attributes | |
std::size_t | m_Hash |
Allows Type to be hashable, use operator==, and use operator!=.
First, Type should implement std::size_t Hash() const noexcept. Whenever your data is mutated, including at constructor-time, you must call onHashChanged(). If you are concerned with hash conflicts, then Type should implement bool Equals(const Type& other) const noexcept and operator== will also verify for strong equality. Otherwise, it will only compare hashes. This abstraction is especially efficient for compound types.
Type | the data type that must be Equatable |
Definition at line 28 of file IEquatable.hxx.
IEquatable< Type >::IEquatable |
|
protectednoexcept |
|
protectednoexcept |
Call when the hash has changed.
hash | the new hash |
Definition at line 26 of file IEquatable.inl.hxx.
|
constexprnoexcept |
Definition at line 9 of file IEquatable.inl.hxx.
|
noexcept |
|
private |
Definition at line 32 of file IEquatable.hxx.