config.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*=============================================================================
  2. Copyright (c) 2014 Eric Niebler
  3. Copyright (c) 2014,2015,2018 Kohei Takahashi
  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. #if !defined(FUSION_SUPPORT_CONFIG_01092014_1718)
  8. #define FUSION_SUPPORT_CONFIG_01092014_1718
  9. #include <boost/config.hpp>
  10. #include <boost/detail/workaround.hpp>
  11. #include <utility>
  12. #ifndef BOOST_FUSION_GPU_ENABLED
  13. #define BOOST_FUSION_GPU_ENABLED BOOST_GPU_ENABLED
  14. #endif
  15. // Enclose with inline namespace because unqualified lookup of GCC < 4.5 is broken.
  16. //
  17. // namespace detail {
  18. // struct foo;
  19. // struct X { };
  20. // }
  21. //
  22. // template <typename T> void foo(T) { }
  23. //
  24. // int main()
  25. // {
  26. // foo(detail::X());
  27. // // prog.cc: In function 'int main()':
  28. // // prog.cc:2: error: 'struct detail::foo' is not a function,
  29. // // prog.cc:6: error: conflict with 'template<class T> void foo(T)'
  30. // // prog.cc:10: error: in call to 'foo'
  31. // }
  32. namespace boost { namespace fusion { namespace detail
  33. {
  34. namespace barrier { }
  35. using namespace barrier;
  36. }}}
  37. #define BOOST_FUSION_BARRIER_BEGIN namespace barrier {
  38. #define BOOST_FUSION_BARRIER_END }
  39. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1900))
  40. // All of rvalue-reference ready MSVC don't perform implicit conversion from
  41. // fundamental type to rvalue-reference of another fundamental type [1].
  42. //
  43. // Following example doesn't compile
  44. //
  45. // int i;
  46. // long &&l = i; // sigh..., std::forward<long&&>(i) also fail.
  47. //
  48. // however, following one will work.
  49. //
  50. // int i;
  51. // long &&l = static_cast<long &&>(i);
  52. //
  53. // OK, now can we replace all usage of std::forward to static_cast? -- I say NO!
  54. // All of rvalue-reference ready Clang doesn't compile above static_cast usage [2], sigh...
  55. //
  56. // References:
  57. // 1. https://connect.microsoft.com/VisualStudio/feedback/details/1037806/implicit-conversion-doesnt-perform-for-fund
  58. // 2. http://llvm.org/bugs/show_bug.cgi?id=19917
  59. //
  60. // Tentatively, we use static_cast to forward if run under MSVC.
  61. # define BOOST_FUSION_FWD_ELEM(type, value) static_cast<type&&>(value)
  62. #else
  63. # define BOOST_FUSION_FWD_ELEM(type, value) std::forward<type>(value)
  64. #endif
  65. // Workaround for LWG 2408: C++17 SFINAE-friendly std::iterator_traits.
  66. // http://cplusplus.github.io/LWG/lwg-defects.html#2408
  67. //
  68. // - GCC 4.5 enables the feature under C++11.
  69. // https://gcc.gnu.org/ml/gcc-patches/2014-11/msg01105.html
  70. //
  71. // - MSVC 10.0 implements iterator intrinsics; MSVC 13.0 implements LWG2408.
  72. #if (defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 40500) && \
  73. defined(BOOST_LIBSTDCXX11)) || \
  74. (defined(BOOST_MSVC) && (1600 <= BOOST_MSVC && BOOST_MSVC < 1900))
  75. # define BOOST_FUSION_WORKAROUND_FOR_LWG_2408
  76. namespace std
  77. {
  78. template <typename>
  79. struct iterator_traits;
  80. }
  81. #endif
  82. // Workaround for older GCC that doesn't accept `this` in constexpr.
  83. #if BOOST_WORKAROUND(BOOST_GCC, < 40700)
  84. #define BOOST_FUSION_CONSTEXPR_THIS
  85. #else
  86. #define BOOST_FUSION_CONSTEXPR_THIS BOOST_CONSTEXPR
  87. #endif
  88. // Workaround for compilers not implementing N3031 (DR743 and DR950).
  89. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913)) || \
  90. BOOST_WORKAROUND(BOOST_GCC, < 40700) || \
  91. defined(BOOST_CLANG) && (__clang_major__ == 3 && __clang_minor__ == 0)
  92. # if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  93. namespace boost { namespace fusion { namespace detail
  94. {
  95. template <typename T>
  96. using type_alias_t = T;
  97. }}}
  98. # define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
  99. boost::fusion::detail::type_alias_t<decltype parenthesized_expr>
  100. # else
  101. # include <boost/mpl/identity.hpp>
  102. # define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
  103. boost::mpl::identity<decltype parenthesized_expr>::type
  104. # endif
  105. #else
  106. # define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
  107. decltype parenthesized_expr
  108. #endif
  109. // Workaround for GCC 4.6 that rejects defaulted function with noexcept.
  110. #if BOOST_WORKAROUND(BOOST_GCC, / 100 == 406)
  111. # define BOOST_FUSION_NOEXCEPT_ON_DEFAULTED
  112. #else
  113. # define BOOST_FUSION_NOEXCEPT_ON_DEFAULTED BOOST_NOEXCEPT
  114. #endif
  115. #endif