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.
 
 
 

90 lines
1.5 KiB

  1. #pragma once
  2. #include <cstddef>
  3. #include <type_traits>
  4. #include <cppmp/config.h>
  5. namespace cppmp
  6. {
  7. /**
  8. * @brief Evaluates to void.
  9. */
  10. template<typename...>
  11. using void_t = void;
  12. /**
  13. * @brief Store a single type.
  14. */
  15. template<typename X>
  16. struct type_t
  17. { };
  18. #ifdef cppmp_supports_variable_templates
  19. template<typename X>
  20. constexpr decltype(auto) type_v = type_t<X> { };
  21. #endif
  22. /**
  23. * @brief Simple type list.
  24. */
  25. template<typename...>
  26. struct list
  27. { };
  28. /**
  29. * @brief Inherit from all passed types.
  30. */
  31. template<typename... T>
  32. struct inherit
  33. : public T...
  34. { };
  35. /**
  36. * @brief Type to wrap constant values at compile time.
  37. */
  38. template<typename T, T t>
  39. struct integral_constant
  40. : public std::integral_constant<T, t>
  41. { };
  42. /**
  43. * @brief Boolean constant type.
  44. */
  45. template<bool B>
  46. struct bool_t
  47. : public integral_constant<bool, B>
  48. { };
  49. /**
  50. * @brief True boolean constant type.
  51. */
  52. struct true_t
  53. : public bool_t<true>
  54. { };
  55. /**
  56. * @brief False boolean constant type.
  57. */
  58. struct false_t
  59. : public bool_t<false>
  60. { };
  61. /**
  62. * @brief Size contant type.
  63. */
  64. template<size_t S>
  65. struct size_t
  66. : public integral_constant<std::size_t, S>
  67. { };
  68. /**
  69. * @brief Zero zize constant type.
  70. */
  71. struct zero_t
  72. : public size_t<0>
  73. { };
  74. }