xref: /netbsd-src/external/gpl3/gcc.old/dist/libphobos/libdruntime/rt/typeinfo/ti_uint.d (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1 /**
2  * TypeInfo support code.
3  *
4  * Copyright: Copyright Digital Mars 2004 - 2009.
5  * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
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  */
14 module rt.typeinfo.ti_uint;
15 
16 // uint
17 
18 class TypeInfo_k : TypeInfo
19 {
20     @trusted:
21     const:
22     pure:
23     nothrow:
24 
toString()25     override string toString() const pure nothrow @safe { return "uint"; }
26 
getHash(scope const void * p)27     override size_t getHash(scope const void* p)
28     {
29         return *cast(const uint *)p;
30     }
31 
equals(in void * p1,in void * p2)32     override bool equals(in void* p1, in void* p2)
33     {
34         return *cast(uint *)p1 == *cast(uint *)p2;
35     }
36 
compare(in void * p1,in void * p2)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 
tsize()46     override @property size_t tsize() nothrow pure
47     {
48         return uint.sizeof;
49     }
50 
initializer()51     override const(void)[] initializer() const @trusted
52     {
53         return (cast(void *)null)[0 .. uint.sizeof];
54     }
55 
swap(void * p1,void * p2)56     override void swap(void *p1, void *p2)
57     {
58         int t;
59 
60         t = *cast(uint *)p1;
61         *cast(uint *)p1 = *cast(uint *)p2;
62         *cast(uint *)p2 = t;
63     }
64 }
65