JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
jh::concepts::extended_hashable Concept Reference

Concept for types that can be hashed through any supported mechanism. More...

#include <jh/conceptual/hashable.h>

Concept definition

template<typename T>
Concept for types that can be hashed through any supported mechanism.
Definition hashable.h:135
Checks whether a free (ADL-discoverable) hash() function exists.
Definition hashable.h:93
Checks whether a type defines a hash() member function.
Definition hashable.h:106
Checks whether std::hash<T> is valid and callable.
Definition hashable.h:79

Detailed Description

Concept for types that can be hashed through any supported mechanism.

A type T satisfies extended_hashable if it supports at least one of the following:

  1. std::hash<T> specialization
  2. ADL-discoverable hash() free function
  3. Member function T::hash()

The precedence follows:

std::hash<T>{}(t) > hash(t) > t.hash()

This ensures that standard hash behavior dominates if explicitly defined, while still enabling semantic extensions and user customization.