/src/rt/typeinfo/ti_delegate.d
D | 57 lines | 33 code | 11 blank | 13 comment | 1 complexity | b550b1b0324fa0f1ab68ffc0ccdfaf9b MD5 | raw file
1/** 2 * TypeInfo support code. 3 * 4 * Copyright: Copyright Digital Mars 2004 - 2009. 5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. 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_delegate; 15 16private import rt.util.hash; 17 18// delegate 19 20alias void delegate(int) dg; 21 22class TypeInfo_D : TypeInfo 23{ 24 @trusted: 25 const: 26 pure: 27 nothrow: 28 29 override size_t getHash(in void* p) 30 { 31 return hashOf(p, dg.sizeof); 32 } 33 34 override bool equals(in void* p1, in void* p2) 35 { 36 return *cast(dg *)p1 == *cast(dg *)p2; 37 } 38 39 override @property size_t tsize() nothrow pure 40 { 41 return dg.sizeof; 42 } 43 44 override void swap(void *p1, void *p2) 45 { 46 dg t; 47 48 t = *cast(dg *)p1; 49 *cast(dg *)p1 = *cast(dg *)p2; 50 *cast(dg *)p2 = t; 51 } 52 53 override @property uint flags() nothrow pure 54 { 55 return 1; 56 } 57}