1/** 2 * TypeInfo support code. 3 * 4 * Copyright: Copyright Digital Mars 2016. 5 * License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 * Authors: Kenji Hara 7 */ 8 9/* Copyright Digital Mars 2016. 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_n; 15 16// typeof(null) 17 18class TypeInfo_n : TypeInfo 19{ 20 override string toString() const @safe { return "typeof(null)"; } 21 22 override size_t getHash(scope const void* p) const 23 { 24 return 0; 25 } 26 27 override bool equals(in void* p1, in void* p2) const @trusted 28 { 29 //return *cast(typeof(null)*)p1 is *cast(typeof(null)*)p2; 30 return true; 31 } 32 33 override int compare(in void* p1, in void* p2) const @trusted 34 { 35 //if (*cast(int*) p1 < *cast(int*) p2) 36 // return -1; 37 //else if (*cast(int*) p1 > *cast(int*) p2) 38 // return 1; 39 return 0; 40 } 41 42 override @property size_t tsize() const 43 { 44 return typeof(null).sizeof; 45 } 46 47 override const(void)[] initializer() const @trusted 48 { 49 return (cast(void*)null)[0 .. typeof(null).sizeof]; 50 } 51 52 override void swap(void *p1, void *p2) const @trusted 53 { 54 //auto t = *cast(typeof(null)*)p1; 55 //*cast(typeof(null)*)p1 = *cast(typeof(null)*)p2; 56 //*cast(typeof(null)*)p2 = t; 57 } 58} 59