From c8bee92fb9ae1479077071cd5ffed58be77d0b26 Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Sun, 7 Nov 2021 14:50:41 +0100 Subject: [PATCH] AK: Add the concept of hash-compatible types --- AK/Concepts.h | 3 +++ AK/StdLibExtraDetails.h | 7 +++++++ AK/StringUtils.h | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/AK/Concepts.h b/AK/Concepts.h index 2996e43633b..00580face5f 100644 --- a/AK/Concepts.h +++ b/AK/Concepts.h @@ -36,6 +36,9 @@ concept SameAs = IsSame; template concept AnyString = Detail::IsConstructible; +template +concept HashCompatible = IsHashCompatible, Detail::Decay>; + // FIXME: remove once Clang formats these properly. // clang-format off template diff --git a/AK/StdLibExtraDetails.h b/AK/StdLibExtraDetails.h index 0235022f04a..1b91e337516 100644 --- a/AK/StdLibExtraDetails.h +++ b/AK/StdLibExtraDetails.h @@ -575,6 +575,12 @@ using Decay = typename __decay::type; template inline constexpr bool IsPointerOfType = IsPointer>&& IsSame>>>; + +template +inline constexpr bool IsHashCompatible = false; +template +inline constexpr bool IsHashCompatible = true; + } using AK::Detail::AddConst; using AK::Detail::AddLvalueReference; @@ -605,6 +611,7 @@ using AK::Detail::IsEnum; using AK::Detail::IsFloatingPoint; using AK::Detail::IsFunction; using AK::Detail::IsFundamental; +using AK::Detail::IsHashCompatible; using AK::Detail::IsIntegral; using AK::Detail::IsLvalueReference; using AK::Detail::IsMoveAssignable; diff --git a/AK/StringUtils.h b/AK/StringUtils.h index 13794c4d0c9..ca079cb82ad 100644 --- a/AK/StringUtils.h +++ b/AK/StringUtils.h @@ -7,10 +7,16 @@ #pragma once +#include #include namespace AK { +namespace Detail { +template +inline constexpr bool IsHashCompatible = true; +} + enum class CaseSensitivity { CaseInsensitive, CaseSensitive,