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 */ 14module rt.typeinfo.ti_byte; 15 16// byte 17 18class TypeInfo_g : TypeInfo 19{ 20 @trusted: 21 const: 22 pure: 23 nothrow: 24 25 override string toString() const pure nothrow @safe { return "byte"; } 26 27 override size_t getHash(scope const void* p) 28 { 29 return *cast(const byte *)p; 30 } 31 32 override bool equals(in void* p1, in void* p2) 33 { 34 return *cast(byte *)p1 == *cast(byte *)p2; 35 } 36 37 override int compare(in void* p1, in void* p2) 38 { 39 return *cast(byte *)p1 - *cast(byte *)p2; 40 } 41 42 override @property size_t tsize() nothrow pure 43 { 44 return byte.sizeof; 45 } 46 47 override const(void)[] initializer() @trusted 48 { 49 return (cast(void *)null)[0 .. byte.sizeof]; 50 } 51 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} 61