xref: /netbsd-src/external/gpl3/gcc.old/dist/libphobos/libdruntime/rt/typeinfo/ti_void.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_void;
15 
16 // void
17 
18 class TypeInfo_v : TypeInfo
19 {
20     @trusted:
21     const:
22     pure:
23     nothrow:
24 
toString()25     override string toString() const pure nothrow @safe { return "void"; }
26 
getHash(scope const void * p)27     override size_t getHash(scope const void* p)
28     {
29         assert(0);
30     }
31 
equals(in void * p1,in void * p2)32     override bool equals(in void* p1, in void* p2)
33     {
34         return *cast(byte *)p1 == *cast(byte *)p2;
35     }
36 
compare(in void * p1,in void * p2)37     override int compare(in void* p1, in void* p2)
38     {
39         return *cast(byte *)p1 - *cast(byte *)p2;
40     }
41 
tsize()42     override @property size_t tsize() nothrow pure
43     {
44         return void.sizeof;
45     }
46 
initializer()47     override const(void)[] initializer() const @trusted
48     {
49         return (cast(void *)null)[0 .. void.sizeof];
50     }
51 
swap(void * p1,void * p2)52     override void swap(void *p1, void *p2)
53     {
54         byte t;
55 
56         t = *cast(byte *)p1;
57         *cast(byte *)p1 = *cast(byte *)p2;
58         *cast(byte *)p2 = t;
59     }
60 
flags()61     override @property uint flags() nothrow pure
62     {
63         return 1;
64     }
65 }
66