PageRenderTime 24ms CodeModel.GetById 19ms app.highlight 4ms RepoModel.GetById 0ms app.codeStats 0ms

/src/rt/typeinfo/ti_ulong.d

http://github.com/AlexeyProkhin/druntime
D | 66 lines | 41 code | 12 blank | 13 comment | 4 complexity | 6999a0e33c6acb5380e32acab6e91ea2 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_ulong;
15
16private import rt.util.hash;
17
18// ulong
19
20class TypeInfo_m : TypeInfo
21{
22    @trusted:
23    const:
24    pure:
25    nothrow:
26
27    override string toString() const pure nothrow @safe { return "ulong"; }
28
29    override size_t getHash(in void* p)
30    {
31        return hashOf(p, ulong.sizeof);
32    }
33
34    override bool equals(in void* p1, in void* p2)
35    {
36        return *cast(ulong *)p1 == *cast(ulong *)p2;
37    }
38
39    override int compare(in void* p1, in void* p2)
40    {
41        if (*cast(ulong *)p1 < *cast(ulong *)p2)
42            return -1;
43        else if (*cast(ulong *)p1 > *cast(ulong *)p2)
44            return 1;
45        return 0;
46    }
47
48    override @property size_t tsize() nothrow pure
49    {
50        return ulong.sizeof;
51    }
52
53    override void swap(void *p1, void *p2)
54    {
55        ulong t;
56
57        t = *cast(ulong *)p1;
58        *cast(ulong *)p1 = *cast(ulong *)p2;
59        *cast(ulong *)p2 = t;
60    }
61
62    override @property size_t talign() nothrow pure
63    {
64        return ulong.alignof;
65    }
66}