config.hpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*=============================================================================
  2. Copyright (c) 2016 Paul Fultz II
  3. config.hpp
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #ifndef BOOST_HOF_GUARD_CONFIG_HPP
  8. #define BOOST_HOF_GUARD_CONFIG_HPP
  9. // Unpack has extra checks to ensure that the function will be invoked with
  10. // the sequence. This extra check can help improve error reporting but it can
  11. // slow down compilation. This is enabled by default.
  12. #ifndef BOOST_HOF_CHECK_UNPACK_SEQUENCE
  13. #define BOOST_HOF_CHECK_UNPACK_SEQUENCE 1
  14. #endif
  15. // Check for std version
  16. #if __cplusplus >= 201606
  17. #define BOOST_HOF_HAS_STD_17 1
  18. #else
  19. #define BOOST_HOF_HAS_STD_17 0
  20. #endif
  21. #if __cplusplus >= 201402
  22. #define BOOST_HOF_HAS_STD_14 1
  23. #else
  24. #define BOOST_HOF_HAS_STD_14 0
  25. #endif
  26. #if __cplusplus >= 201103
  27. #define BOOST_HOF_HAS_STD_11 1
  28. #else
  29. #define BOOST_HOF_HAS_STD_11 0
  30. #endif
  31. // This determines if it safe to use inheritance for EBO. On every platform
  32. // except clang, compilers have problems with ambigous base conversion. So
  33. // this configures the library to use a different technique to achieve empty
  34. // optimization.
  35. #ifndef BOOST_HOF_HAS_EBO
  36. #ifdef __clang__
  37. #define BOOST_HOF_HAS_EBO 1
  38. #else
  39. #define BOOST_HOF_HAS_EBO 0
  40. #endif
  41. #endif
  42. // This configures the library whether expression sfinae can be used to detect
  43. // callability of a function.
  44. #ifndef BOOST_HOF_NO_EXPRESSION_SFINAE
  45. #ifdef _MSC_VER
  46. #define BOOST_HOF_NO_EXPRESSION_SFINAE 1
  47. #else
  48. #define BOOST_HOF_NO_EXPRESSION_SFINAE 0
  49. #endif
  50. #endif
  51. // This configures the library to use manual type deduction in a few places
  52. // where it problematic on a few platforms.
  53. #ifndef BOOST_HOF_HAS_MANUAL_DEDUCTION
  54. #if (defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 8)
  55. #define BOOST_HOF_HAS_MANUAL_DEDUCTION 1
  56. #else
  57. #define BOOST_HOF_HAS_MANUAL_DEDUCTION 0
  58. #endif
  59. #endif
  60. // Whether the compiler has relaxed constexpr.
  61. #ifndef BOOST_HOF_HAS_RELAXED_CONSTEXPR
  62. #ifdef __cpp_constexpr
  63. #if __cpp_constexpr >= 201304
  64. #define BOOST_HOF_HAS_RELAXED_CONSTEXPR 1
  65. #else
  66. #define BOOST_HOF_HAS_RELAXED_CONSTEXPR 0
  67. #endif
  68. #else
  69. #define BOOST_HOF_HAS_RELAXED_CONSTEXPR BOOST_HOF_HAS_STD_14
  70. #endif
  71. #endif
  72. // Whether the compiler supports generic lambdas
  73. #ifndef BOOST_HOF_HAS_GENERIC_LAMBDA
  74. #if defined(__cpp_generic_lambdas) || defined(_MSC_VER)
  75. #define BOOST_HOF_HAS_GENERIC_LAMBDA 1
  76. #else
  77. #define BOOST_HOF_HAS_GENERIC_LAMBDA BOOST_HOF_HAS_STD_14
  78. #endif
  79. #endif
  80. // Whether the compiler supports constexpr lambdas
  81. #ifndef BOOST_HOF_HAS_CONSTEXPR_LAMBDA
  82. #if defined(__cpp_constexpr) && __cpp_constexpr >= 201603
  83. #define BOOST_HOF_HAS_CONSTEXPR_LAMBDA 1
  84. #else
  85. #define BOOST_HOF_HAS_CONSTEXPR_LAMBDA BOOST_HOF_HAS_STD_17
  86. #endif
  87. #endif
  88. // Whether the compiler supports inline variables
  89. #ifndef BOOST_HOF_HAS_INLINE_VARIABLES
  90. #if defined(__cpp_inline_variables)
  91. #define BOOST_HOF_HAS_INLINE_VARIABLES 1
  92. #else
  93. #define BOOST_HOF_HAS_INLINE_VARIABLES BOOST_HOF_HAS_STD_17
  94. #endif
  95. #endif
  96. // Whether inline variables defined with lambdas have external linkage.
  97. // Currently, no compiler supports this yet.
  98. #ifndef BOOST_HOF_HAS_INLINE_LAMBDAS
  99. #define BOOST_HOF_HAS_INLINE_LAMBDAS 0
  100. #endif
  101. // Whether the compiler supports variable templates
  102. #ifndef BOOST_HOF_HAS_VARIABLE_TEMPLATES
  103. #if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 5
  104. #define BOOST_HOF_HAS_VARIABLE_TEMPLATES 0
  105. #elif defined(__cpp_variable_templates)
  106. #define BOOST_HOF_HAS_VARIABLE_TEMPLATES 1
  107. #else
  108. #define BOOST_HOF_HAS_VARIABLE_TEMPLATES BOOST_HOF_HAS_STD_14
  109. #endif
  110. #endif
  111. // Whether a constexpr function can use a void return type
  112. #ifndef BOOST_HOF_NO_CONSTEXPR_VOID
  113. #if BOOST_HOF_HAS_RELAXED_CONSTEXPR
  114. #define BOOST_HOF_NO_CONSTEXPR_VOID 0
  115. #else
  116. #define BOOST_HOF_NO_CONSTEXPR_VOID 1
  117. #endif
  118. #endif
  119. // Whether to use template aliases
  120. #ifndef BOOST_HOF_HAS_TEMPLATE_ALIAS
  121. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 8
  122. #define BOOST_HOF_HAS_TEMPLATE_ALIAS 0
  123. #else
  124. #define BOOST_HOF_HAS_TEMPLATE_ALIAS 1
  125. #endif
  126. #endif
  127. // Whether evaluations of function in brace initialization is ordered from
  128. // left-to-right.
  129. #ifndef BOOST_HOF_NO_ORDERED_BRACE_INIT
  130. #if (defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 9) || defined(_MSC_VER)
  131. #define BOOST_HOF_NO_ORDERED_BRACE_INIT 1
  132. #else
  133. #define BOOST_HOF_NO_ORDERED_BRACE_INIT 0
  134. #endif
  135. #endif
  136. // Whether the compiler has trouble mangling some expressions used in
  137. // decltype.
  138. #ifndef BOOST_HOF_HAS_MANGLE_OVERLOAD
  139. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
  140. #define BOOST_HOF_HAS_MANGLE_OVERLOAD 0
  141. #else
  142. #define BOOST_HOF_HAS_MANGLE_OVERLOAD 1
  143. #endif
  144. #endif
  145. // Whether an incomplete 'this' pointer can be used in a trailing decltype.
  146. #ifndef BOOST_HOF_HAS_COMPLETE_DECLTYPE
  147. #if !BOOST_HOF_HAS_MANGLE_OVERLOAD || (defined(__GNUC__) && !defined (__clang__))
  148. #define BOOST_HOF_HAS_COMPLETE_DECLTYPE 0
  149. #else
  150. #define BOOST_HOF_HAS_COMPLETE_DECLTYPE 1
  151. #endif
  152. #endif
  153. // Whether function will deduce noexcept from an expression
  154. #ifndef BOOST_HOF_HAS_NOEXCEPT_DEDUCTION
  155. #if defined(__GNUC__) && !defined (__clang__) && ((__GNUC__ == 4 && __GNUC_MINOR__ < 8) || (__GNUC__ == 7 && __GNUC_MINOR__ == 1))
  156. #define BOOST_HOF_HAS_NOEXCEPT_DEDUCTION 0
  157. #else
  158. #define BOOST_HOF_HAS_NOEXCEPT_DEDUCTION 1
  159. #endif
  160. #endif
  161. // Some type expansion failures on gcc 4.6
  162. #ifndef BOOST_HOF_NO_TYPE_PACK_EXPANSION_IN_TEMPLATE
  163. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
  164. #define BOOST_HOF_NO_TYPE_PACK_EXPANSION_IN_TEMPLATE 1
  165. #else
  166. #define BOOST_HOF_NO_TYPE_PACK_EXPANSION_IN_TEMPLATE 0
  167. #endif
  168. #endif
  169. // Whether to use std::default_constructible, it is a little buggy on gcc 4.6.
  170. #ifndef BOOST_HOF_NO_STD_DEFAULT_CONSTRUCTIBLE
  171. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
  172. #define BOOST_HOF_NO_STD_DEFAULT_CONSTRUCTIBLE 1
  173. #else
  174. #define BOOST_HOF_NO_STD_DEFAULT_CONSTRUCTIBLE 0
  175. #endif
  176. #endif
  177. #endif