PageRenderTime 17ms CodeModel.GetById 7ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/rt/typeinfo/ti_ubyte.d

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