Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IEquatable.hxx
Go to the documentation of this file.
1 #ifndef IEQUATABLE_HXX_
2 #define IEQUATABLE_HXX_
3 
4 #include "Meta.hxx"
5 
9 template <typename Type, typename = void> struct is_strong_equatable_type : public std::false_type
10 {
11 };
12 
13 template <typename Type>
14 struct is_strong_equatable_type<Type, std::void_t<decltype(std::declval<Type>().Equals(std::declval<Type>()))>> : std::true_type
15 {
16 };
17 
28 template <typename Type> class IEquatable
29 {
30 
31 private:
32  std::size_t m_Hash;
33 
34 public:
38  IEquatable();
39 
43  constexpr bool operator!=(const IEquatable<Type> &other) const noexcept;
44 
48  bool operator==(const IEquatable<Type> &other) const noexcept;
49 
50 protected:
55  void onHashChanged(std::size_t hash) noexcept;
56 
60  void onHashChanged() noexcept;
61 };
62 
63 #include "IEquatable.inl.hxx"
64 
65 #endif
IEquatable::operator!=
constexpr bool operator!=(const IEquatable< Type > &other) const noexcept
Definition: IEquatable.inl.hxx:9
IEquatable::IEquatable
IEquatable()
Create an Equatable type.
Definition: IEquatable.inl.hxx:2
IEquatable::m_Hash
std::size_t m_Hash
Definition: IEquatable.hxx:32
IEquatable::onHashChanged
void onHashChanged() noexcept
Call when the hash has changed.
Definition: IEquatable.inl.hxx:27
Meta.hxx
std
Definition: Point.hxx:83
IEquatable::operator==
bool operator==(const IEquatable< Type > &other) const noexcept
Definition: IEquatable.inl.hxx:14
is_strong_equatable_type
Is true if a type is strongly equatable.
Definition: IEquatable.hxx:9
IEquatable
Allows Type to be hashable, use operator==, and use operator!=.
Definition: IEquatable.hxx:28