]> gcc.gnu.org Git - gcc.git/blob - libphobos/libdruntime/rt/typeinfo/ti_ptr.d
Add D front-end, libphobos library, and D2 testsuite.
[gcc.git] / libphobos / libdruntime / rt / typeinfo / ti_ptr.d
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_ptr;
15
16 // internal typeinfo for any pointer type
17 // please keep in sync with TypeInfo_Pointer
18
19 class TypeInfo_P : TypeInfo
20 {
21 @trusted:
22 const:
23 pure:
24 nothrow:
25
26 override size_t getHash(in void* p)
27 {
28 return cast(size_t)*cast(void**)p;
29 }
30
31 override bool equals(in void* p1, in void* p2)
32 {
33 return *cast(void**)p1 == *cast(void**)p2;
34 }
35
36 override int compare(in void* p1, in void* p2)
37 {
38 if (*cast(void**)p1 < *cast(void**)p2)
39 return -1;
40 else if (*cast(void**)p1 > *cast(void**)p2)
41 return 1;
42 else
43 return 0;
44 }
45
46 override @property size_t tsize() nothrow pure
47 {
48 return (void*).sizeof;
49 }
50
51 override const(void)[] initializer() const @trusted
52 {
53 return (cast(void *)null)[0 .. (void*).sizeof];
54 }
55
56 override void swap(void *p1, void *p2)
57 {
58 void* tmp = *cast(void**)p1;
59 *cast(void**)p1 = *cast(void**)p2;
60 *cast(void**)p2 = tmp;
61 }
62
63 override @property uint flags() nothrow pure const { return 1; }
64 }
This page took 0.038749 seconds and 5 git commands to generate.