config.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // MPark.Variant
  2. //
  3. // Copyright Michael Park, 2015-2017
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. #ifndef MPARK_CONFIG_HPP
  8. #define MPARK_CONFIG_HPP
  9. // MSVC 2015 Update 3.
  10. #if __cplusplus < 201103L && (!defined(_MSC_VER) || _MSC_FULL_VER < 190024210)
  11. #error "MPark.Variant requires C++11 support."
  12. #endif
  13. #ifndef __has_attribute
  14. #define __has_attribute(x) 0
  15. #endif
  16. #ifndef __has_builtin
  17. #define __has_builtin(x) 0
  18. #endif
  19. #ifndef __has_include
  20. #define __has_include(x) 0
  21. #endif
  22. #ifndef __has_feature
  23. #define __has_feature(x) 0
  24. #endif
  25. #if __has_attribute(always_inline) || defined(__GNUC__)
  26. #define MPARK_ALWAYS_INLINE __attribute__((__always_inline__)) inline
  27. #elif defined(_MSC_VER)
  28. #define MPARK_ALWAYS_INLINE __forceinline
  29. #else
  30. #define MPARK_ALWAYS_INLINE inline
  31. #endif
  32. #if __has_builtin(__builtin_addressof) || \
  33. (defined(__GNUC__) && __GNUC__ >= 7) || defined(_MSC_VER)
  34. #define MPARK_BUILTIN_ADDRESSOF
  35. #endif
  36. #if __has_builtin(__builtin_unreachable) || defined(__GNUC__)
  37. #define MPARK_BUILTIN_UNREACHABLE __builtin_unreachable()
  38. #elif defined(_MSC_VER)
  39. #define MPARK_BUILTIN_UNREACHABLE __assume(false)
  40. #else
  41. #define MPARK_BUILTIN_UNREACHABLE
  42. #endif
  43. #if __has_builtin(__type_pack_element)
  44. #define MPARK_TYPE_PACK_ELEMENT
  45. #endif
  46. #if defined(__cpp_constexpr) && __cpp_constexpr >= 200704 && \
  47. !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 9)
  48. #define MPARK_CPP11_CONSTEXPR
  49. #endif
  50. #if defined(__cpp_constexpr) && __cpp_constexpr >= 201304
  51. #define MPARK_CPP14_CONSTEXPR
  52. #endif
  53. #if __has_feature(cxx_exceptions) || defined(__cpp_exceptions) || \
  54. (defined(_MSC_VER) && defined(_CPPUNWIND))
  55. #define MPARK_EXCEPTIONS
  56. #endif
  57. #if defined(__cpp_generic_lambdas) || defined(_MSC_VER)
  58. #define MPARK_GENERIC_LAMBDAS
  59. #endif
  60. #if defined(__cpp_lib_integer_sequence)
  61. #define MPARK_INTEGER_SEQUENCE
  62. #endif
  63. #if defined(__cpp_return_type_deduction) || defined(_MSC_VER)
  64. #define MPARK_RETURN_TYPE_DEDUCTION
  65. #endif
  66. #if defined(__cpp_lib_transparent_operators) || defined(_MSC_VER)
  67. #define MPARK_TRANSPARENT_OPERATORS
  68. #endif
  69. #if defined(__cpp_variable_templates) || defined(_MSC_VER)
  70. #define MPARK_VARIABLE_TEMPLATES
  71. #endif
  72. #if !defined(__GLIBCXX__) || __has_include(<codecvt>) // >= libstdc++-5
  73. #define MPARK_TRIVIALITY_TYPE_TRAITS
  74. #define MPARK_INCOMPLETE_TYPE_TRAITS
  75. #endif
  76. #endif // MPARK_CONFIG_HPP