#pragma once #include "HashFunctions.h" #include "kstdio.h" namespace AK { template struct GenericTraits { using PeekType = T; static constexpr bool is_trivial() { return false; } static bool equals(const T& a, const T& b) { return a == b; } }; template struct Traits : public GenericTraits { }; template<> struct Traits : public GenericTraits { static constexpr bool is_trivial() { return true; } static unsigned hash(int i) { return int_hash(i); } static void dump(int i) { kprintf("%d", i); } }; template<> struct Traits : public GenericTraits { static constexpr bool is_trivial() { return true; } static unsigned hash(unsigned u) { return int_hash(u); } static void dump(unsigned u) { kprintf("%u", u); } }; template<> struct Traits : public GenericTraits { static constexpr bool is_trivial() { return true; } static unsigned hash(u16 u) { return int_hash(u); } static void dump(u16 u) { kprintf("%u", u); } }; template<> struct Traits : public GenericTraits { static constexpr bool is_trivial() { return true; } static unsigned hash(char c) { return int_hash(c); } static void dump(char c) { kprintf("%c", c); } }; template struct Traits : public GenericTraits { static unsigned hash(const T* p) { return int_hash((unsigned)(__PTRDIFF_TYPE__)p); } static constexpr bool is_trivial() { return true; } static void dump(const T* p) { kprintf("%p", p); } static bool equals(const T* a, const T* b) { return a == b; } }; }