PageRenderTime 22ms CodeModel.GetById 1ms app.highlight 15ms RepoModel.GetById 2ms app.codeStats 0ms

/src/rt/typeinfo/ti_uint.d

http://github.com/AlexeyProkhin/druntime
D | 59 lines | 36 code | 10 blank | 13 comment | 4 complexity | 0d0a039f02380032350117a319e7af28 MD5 | raw file
 1/**
 2 * TypeInfo support code.
 3 *
 4 * Copyright: Copyright Digital Mars 2004 - 2009.
 5 * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
 6 * Authors:   Walter Bright
 7 */
 8
 9/*          Copyright Digital Mars 2004 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 *    (See accompanying file LICENSE or copy at
12 *          http://www.boost.org/LICENSE_1_0.txt)
13 */
14module rt.typeinfo.ti_uint;
15
16// uint
17
18class TypeInfo_k : TypeInfo
19{
20    @trusted:
21    const:
22    pure:
23    nothrow:
24
25    override string toString() const pure nothrow @safe { return "uint"; }
26
27    override size_t getHash(in void* p)
28    {
29        return *cast(uint *)p;
30    }
31
32    override bool equals(in void* p1, in void* p2)
33    {
34        return *cast(uint *)p1 == *cast(uint *)p2;
35    }
36
37    override int compare(in void* p1, in void* p2)
38    {
39        if (*cast(uint*) p1 < *cast(uint*) p2)
40            return -1;
41        else if (*cast(uint*) p1 > *cast(uint*) p2)
42            return 1;
43        return 0;
44    }
45
46    override @property size_t tsize() nothrow pure
47    {
48        return uint.sizeof;
49    }
50
51    override void swap(void *p1, void *p2)
52    {
53        int t;
54
55        t = *cast(uint *)p1;
56        *cast(uint *)p1 = *cast(uint *)p2;
57        *cast(uint *)p2 = t;
58    }
59}