xref: /netbsd-src/external/gpl3/gcc.old/dist/libphobos/libdruntime/rt/typeinfo/ti_ucent.d (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1 /**
2  * TypeInfo support code.
3  *
4  * Copyright: Copyright Digital Mars 2004 - 2015.
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 - 2015.
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_ucent;
15 
16 static if (is(ucent)):
17 
18 // ucent
19 
20 class TypeInfo_zk : TypeInfo
21 {
22     @trusted:
23     const:
24     pure:
25     nothrow:
26 
toString()27     override string toString() const pure nothrow @safe { return "ucent"; }
28 
getHash(scope const void * p)29     override size_t getHash(scope const void* p)
30     {
31         return hashOf(*cast(const ucent*) p);
32     }
33 
equals(in void * p1,in void * p2)34     override bool equals(in void* p1, in void* p2)
35     {
36         return *cast(ucent *)p1 == *cast(ucent *)p2;
37     }
38 
compare(in void * p1,in void * p2)39     override int compare(in void* p1, in void* p2)
40     {
41         if (*cast(ucent *)p1 < *cast(ucent *)p2)
42             return -1;
43         else if (*cast(ucent *)p1 > *cast(ucent *)p2)
44             return 1;
45         return 0;
46     }
47 
tsize()48     override @property size_t tsize() nothrow pure
49     {
50         return ucent.sizeof;
51     }
52 
initializer()53     override const(void)[] initializer() const @trusted
54     {
55         return (cast(void *)null)[0 .. ucent.sizeof];
56     }
57 
swap(void * p1,void * p2)58     override void swap(void *p1, void *p2)
59     {
60         ucent t;
61 
62         t = *cast(ucent *)p1;
63         *cast(ucent *)p1 = *cast(ucent *)p2;
64         *cast(ucent *)p2 = t;
65     }
66 
talign()67     override @property size_t talign() nothrow pure
68     {
69         return ucent.alignof;
70     }
71 }
72