/src/rt/typeinfo/ti_uint.d

http://github.com/AlexeyProkhin/druntime · D · 59 lines · 36 code · 10 blank · 13 comment · 4 complexity · 0d0a039f02380032350117a319e7af28 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. /* Copyright Digital Mars 2004 - 2009.
  9. * Distributed under the Boost Software License, Version 1.0.
  10. * (See accompanying file LICENSE or copy at
  11. * http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. module rt.typeinfo.ti_uint;
  14. // uint
  15. class TypeInfo_k : TypeInfo
  16. {
  17. @trusted:
  18. const:
  19. pure:
  20. nothrow:
  21. override string toString() const pure nothrow @safe { return "uint"; }
  22. override size_t getHash(in void* p)
  23. {
  24. return *cast(uint *)p;
  25. }
  26. override bool equals(in void* p1, in void* p2)
  27. {
  28. return *cast(uint *)p1 == *cast(uint *)p2;
  29. }
  30. override int compare(in void* p1, in void* p2)
  31. {
  32. if (*cast(uint*) p1 < *cast(uint*) p2)
  33. return -1;
  34. else if (*cast(uint*) p1 > *cast(uint*) p2)
  35. return 1;
  36. return 0;
  37. }
  38. override @property size_t tsize() nothrow pure
  39. {
  40. return uint.sizeof;
  41. }
  42. override void swap(void *p1, void *p2)
  43. {
  44. int t;
  45. t = *cast(uint *)p1;
  46. *cast(uint *)p1 = *cast(uint *)p2;
  47. *cast(uint *)p2 = t;
  48. }
  49. }