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_cent; 15 16 static if (is(cent)): 17 18 // cent 19 20 class TypeInfo_zi : TypeInfo 21 { 22 @trusted: 23 const: 24 pure: 25 nothrow: 26 toString()27 override string toString() const pure nothrow @safe { return "cent"; } 28 getHash(scope const void * p)29 override size_t getHash(scope const void* p) 30 { 31 // cent & ucent hash the same if ucent.sizeof >= size_t.sizeof. 32 return hashOf(*cast(const ucent*) p); 33 } 34 equals(in void * p1,in void * p2)35 override bool equals(in void* p1, in void* p2) 36 { 37 return *cast(cent *)p1 == *cast(cent *)p2; 38 } 39 compare(in void * p1,in void * p2)40 override int compare(in void* p1, in void* p2) 41 { 42 if (*cast(cent *)p1 < *cast(cent *)p2) 43 return -1; 44 else if (*cast(cent *)p1 > *cast(cent *)p2) 45 return 1; 46 return 0; 47 } 48 tsize()49 override @property size_t tsize() nothrow pure 50 { 51 return cent.sizeof; 52 } 53 initializer()54 override const(void)[] initializer() const @trusted 55 { 56 return (cast(void *)null)[0 .. cent.sizeof]; 57 } 58 swap(void * p1,void * p2)59 override void swap(void *p1, void *p2) 60 { 61 cent t; 62 63 t = *cast(cent *)p1; 64 *cast(cent *)p1 = *cast(cent *)p2; 65 *cast(cent *)p2 = t; 66 } 67 talign()68 override @property size_t talign() nothrow pure 69 { 70 return cent.alignof; 71 } 72 } 73