No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

151 líneas
3.3 KiB

  1. #pragma once
  2. #include "types.h"
  3. namespace cppmp
  4. {
  5. namespace __impl
  6. {
  7. /* eval_if_c_impl */
  8. template<bool B, typename T, template<typename...> class E, typename... A>
  9. struct eval_if_impl;
  10. }
  11. /* enable_if */
  12. /**
  13. * @brief Defines T as ::type if B is true, otherwise the resulting type is empty.
  14. */
  15. template<bool B, typename T = void>
  16. struct enable_if
  17. : public std::enable_if<B, T>
  18. { };
  19. /**
  20. * @brief Resulting type is T if B is true. If B is false the resulting type is invalid.
  21. */
  22. template<bool B, typename T = void>
  23. using enable_if_t = typename enable_if<B, T>::type;
  24. /* conditional/if */
  25. /**
  26. * @brief Defines T as ::type if B is true, F otherwise.
  27. */
  28. template<bool B, typename T, typename F>
  29. struct conditional
  30. : public std::conditional<B, T, F>
  31. { };
  32. /**
  33. * @brief Evaluates to T if B is true, to F otherwise.
  34. */
  35. template<bool B, typename T, typename F>
  36. using conditional_t = typename conditional<B, T, F>::type;
  37. /**
  38. * @brief Same as conditional.
  39. */
  40. template<bool B, typename T, typename F>
  41. struct if_
  42. : public conditional<B, T, F>
  43. { };
  44. /**
  45. * @brief Same as conditional_t.
  46. */
  47. template<bool B, typename T, typename F>
  48. using if_t = typename if_<B, T, F>::type;
  49. /* eval_if */
  50. /**
  51. * @brief Defines T as ::type if B is true, evaluates E<A...> otherwise.
  52. */
  53. template<bool B, typename T, template<typename...> class E, typename... A>
  54. struct eval_if
  55. : public __impl::eval_if_impl<B, T, E, A...>
  56. { };
  57. /**
  58. * @brief Evaluates to T if B is true, to E<A...> otherwise.
  59. */
  60. template<bool B, typename T, template<typename...> class E, typename... A>
  61. using eval_if_t = typename eval_if<B, T, E, A...>::type;
  62. /* conjunction/and */
  63. #if __cplusplus >= 201703L
  64. /**
  65. * @brief Evaluates to true_t if all passed arguments are also true_t.
  66. */
  67. template<typename... T>
  68. struct conjunction
  69. : public std::conjunction<T...>
  70. { };
  71. /**
  72. * @brief It to true if all passed arguments are also true_t.
  73. */
  74. template<typename... T>
  75. constexpr decltype(auto) conjunction_v = conjunction<T...>::value;
  76. /**
  77. * @brief Same as conjunction.
  78. */
  79. template<typename... T>
  80. struct and_
  81. : public conjunction<T...>
  82. { };
  83. /**
  84. * @brief Same as conjunction_v.
  85. */
  86. template<typename... T>
  87. constexpr decltype(auto) and_v = conjunction<T...>::value;
  88. #endif
  89. /* disjunction/or */
  90. #if __cplusplus >= 201703L
  91. /**
  92. * @brief Evaluates to true_t if at least one passed arguments is true_t.
  93. */
  94. template<typename... T>
  95. struct disjunction
  96. : public std::disjunction<T...>
  97. { };
  98. /**
  99. * @brief Is true if at least one passed arguments is true_t.
  100. */
  101. template<typename... T>
  102. constexpr decltype(auto) disjunction_v = disjunction<T...>::value;
  103. /**
  104. * @brief Same as disjunction.
  105. */
  106. template<typename... T>
  107. struct or_
  108. : public disjunction<T...>
  109. { };
  110. /**
  111. * @brief Same as disjunction_v.
  112. */
  113. template<typename... T>
  114. constexpr decltype(auto) or_v = disjunction<T...>::value;
  115. #endif
  116. }
  117. #include "conditionals.inl"