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