summaryrefslogtreecommitdiff
path: root/AK/Traits.h
blob: 7c88a2e7cb56596895f8e6e840e3d3fcf4b08ad8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

#include "kstdio.h"
#include "HashFunctions.h"

namespace AK {

template<typename T>
struct Traits 
{
};

template<>
struct Traits<int> {
    static unsigned hash(int i) { return int_hash(i); }
    static void dump(int i) { kprintf("%d", i); }
};

template<>
struct Traits<unsigned> {
    static unsigned hash(unsigned u) { return int_hash(u); }
    static void dump(unsigned u) { kprintf("%u", u); }
};

template<>
struct Traits<word> {
    static unsigned hash(unsigned u) { return int_hash(u); }
    static void dump(unsigned u) { kprintf("%u", u); }
};

template<typename T>
struct Traits<T*> {
    static unsigned hash(const T* p)
    {
        return int_hash((dword)p);
    }
    static void dump(const T* p) { kprintf("%p", p); }
};

}