Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
2.8 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef PANORAMACXX_H
  6. #define PANORAMACXX_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. namespace panorama
  11. {
  12. // TEMPLATE CLASS integral_constant
  13. template<class _Ty,
  14. _Ty _Val>
  15. struct panorama_integral_constant
  16. { // convenient template for integral constant types
  17. static const _Ty value = _Val;
  18. typedef _Ty value_type;
  19. typedef panorama_integral_constant<_Ty, _Val> type;
  20. operator value_type() const
  21. { // return stored value
  22. return (value);
  23. }
  24. };
  25. typedef panorama_integral_constant<bool, true> true_type;
  26. typedef panorama_integral_constant<bool, false> false_type;
  27. // TEMPLATE CLASS _Cat_base
  28. template<bool>
  29. struct panorama_Cat_base
  30. : false_type
  31. { // base class for type predicates
  32. };
  33. template<>
  34. struct panorama_Cat_base < true >
  35. : true_type
  36. { // base class for type predicates
  37. };
  38. // TEMPLATE CLASS enable_if
  39. template<bool _Test,
  40. class _Ty = void>
  41. struct panorama_enable_if
  42. { // type is undefined for assumed !_Test
  43. };
  44. template<class _Ty>
  45. struct panorama_enable_if < true, _Ty >
  46. { // type is _Ty for _Test
  47. typedef _Ty type;
  48. };
  49. #define PANORAMA_IS_BASE_OF(_Base, _Der) \
  50. : panorama_Cat_base<__is_base_of(_Base, _Der)>
  51. // TEMPLATE CLASS is_base_of
  52. template<class _Base, class _Der>
  53. struct panorama_is_base_of PANORAMA_IS_BASE_OF( _Base, _Der )
  54. { // determine whether _Base is a base of or the same as _Der
  55. };
  56. #define PANORAMA_IS_ENUM(_Ty) \
  57. : panorama_Cat_base<__is_enum(_Ty)>
  58. // TEMPLATE CLASS is_enum
  59. template<class _Ty>
  60. struct panorama_is_enum
  61. PANORAMA_IS_ENUM( _Ty )
  62. { // determine whether _Ty is an enumerated type
  63. };
  64. // TEMPLATE CLASS is_lvalue_reference
  65. template<class _Ty>
  66. struct panorama_is_lvalue_reference
  67. : false_type
  68. { // determine whether _Ty is an lvalue reference
  69. };
  70. template<class _Ty>
  71. struct panorama_is_lvalue_reference < _Ty& >
  72. : true_type
  73. { // determine whether _Ty is an lvalue reference
  74. };
  75. // TEMPLATE remove_reference
  76. template<class _Ty>
  77. struct panorama_remove_reference
  78. { // remove reference
  79. typedef _Ty type;
  80. };
  81. template<class _Ty>
  82. struct panorama_remove_reference < _Ty& >
  83. { // remove reference
  84. typedef _Ty type;
  85. };
  86. template<class _Ty>
  87. struct panorama_remove_reference < _Ty&& >
  88. { // remove rvalue reference
  89. typedef _Ty type;
  90. };
  91. // TEMPLATE FUNCTION forward
  92. template<class _Ty> inline
  93. _Ty&& panorama_forward( typename panorama_remove_reference<_Ty>::type& _Arg )
  94. { // forward an lvalue
  95. return (static_cast<_Ty&&>(_Arg));
  96. }
  97. template<class _Ty> inline
  98. _Ty&& panorama_forward( typename panorama_remove_reference<_Ty>::type&& _Arg )
  99. { // forward anything
  100. static_assert(!panorama_is_lvalue_reference<_Ty>::value, "bad forward call");
  101. return (static_cast<_Ty&&>(_Arg));
  102. }
  103. }
  104. #endif // PANORAMACXX_H