ORIGINAL
Loading...
Searching...
No Matches
original::HashTraits Concept Reference

Requires type to implement the hashable interface with toHash method. More...

#include <types.h>

Concept definition

template<typename T>
requires(const T& t) {
{ t.toHash() } -> std::same_as<u_integer>;
} && Equatable<T>
Requires type to implement the hashable interface with toHash method.
Definition types.h:311

Detailed Description

Requires type to implement the hashable interface with toHash method.

Template Parameters
TThe type to check

This concept enforces that a type provides a custom hashing interface through a toHash method and supports equality comparison. Types satisfying this concept can be used with the hashable base class and benefit from automatic STL hash integration.

Requirements:

// Example of a type satisfying HashTraits
class MyHashable {
public:
u_integer toHash() const noexcept {
return std::hash<int>{}(value);
}
bool operator==(const MyHashable& other) const {
return value == other.value;
}
private:
int value;
};
static_assert(HashTraits<MyHashable>); // Succeeds
std::uint32_t u_integer
32-bit unsigned integer type for sizes and indexes
Definition config.h:263

Hash Consistency Requirement:

See also
hashable
hash