xref: /netbsd-src/external/gpl3/gcc.old/dist/libphobos/libdruntime/rt/typeinfo/ti_real.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_real;
15 
16 private import rt.util.typeinfo;
17 
18 // real
19 
20 class TypeInfo_e : TypeInfo
21 {
22   pure:
23   nothrow:
24   @safe:
25 
26     alias F = real;
27 
toString()28     override string toString() const { return F.stringof; }
29 
getHash(scope const void * p)30     override size_t getHash(scope const void* p) const @trusted
31     {
32         return Floating!F.hashOf(*cast(F*)p);
33     }
34 
equals(in void * p1,in void * p2)35     override bool equals(in void* p1, in void* p2) const @trusted
36     {
37         return Floating!F.equals(*cast(F*)p1, *cast(F*)p2);
38     }
39 
compare(in void * p1,in void * p2)40     override int compare(in void* p1, in void* p2) const @trusted
41     {
42         return Floating!F.compare(*cast(F*)p1, *cast(F*)p2);
43     }
44 
tsize()45     override @property size_t tsize() const
46     {
47         return F.sizeof;
48     }
49 
swap(void * p1,void * p2)50     override void swap(void *p1, void *p2) const @trusted
51     {
52         F t = *cast(F*)p1;
53         *cast(F*)p1 = *cast(F*)p2;
54         *cast(F*)p2 = t;
55     }
56 
initializer()57     override const(void)[] initializer() const @trusted
58     {
59         static immutable F r;
60         return (&r)[0 .. 1];
61     }
62 
talign()63     override @property size_t talign() const
64     {
65         return F.alignof;
66     }
67 }
68