1 /*=============================================================================
2 Copyright (c) 2014 Eric Niebler
3 Copyright (c) 2014,2015,2018 Kohei Takahashi
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
11 #include <boost/config.hpp>
12 #include <boost/detail/workaround.hpp>
15 #ifndef BOOST_FUSION_GPU_ENABLED
16 #define BOOST_FUSION_GPU_ENABLED BOOST_GPU_ENABLED
19 // Enclose with inline namespace because unqualified lookup of GCC < 4.5 is broken.
26 // template <typename T> void foo(T) { }
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'
36 namespace boost { namespace fusion { namespace detail
39 using namespace barrier;
41 #define BOOST_FUSION_BARRIER_BEGIN namespace barrier {
42 #define BOOST_FUSION_BARRIER_END }
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].
49 // Following example doesn't compile
52 // long &&l = i; // sigh..., std::forward<long&&>(i) also fail.
54 // however, following one will work.
57 // long &&l = static_cast<long &&>(i);
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...
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
66 // Tentatively, we use static_cast to forward if run under MSVC.
67 # define BOOST_FUSION_FWD_ELEM(type, value) static_cast<type&&>(value)
69 # define BOOST_FUSION_FWD_ELEM(type, value) std::forward<type>(value)
73 // Workaround for LWG 2408: C++17 SFINAE-friendly std::iterator_traits.
74 // http://cplusplus.github.io/LWG/lwg-defects.html#2408
76 // - GCC 4.5 enables the feature under C++11.
77 // https://gcc.gnu.org/ml/gcc-patches/2014-11/msg01105.html
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
87 struct iterator_traits;
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
96 #define BOOST_FUSION_CONSTEXPR_THIS BOOST_CONSTEXPR
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
107 template <typename T>
108 using type_alias_t = T;
110 # define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
111 boost::fusion::detail::type_alias_t<decltype parenthesized_expr>
113 # include <boost/mpl/identity.hpp>
114 # define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
115 boost::mpl::identity<decltype parenthesized_expr>::type
118 # define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
119 decltype parenthesized_expr
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
127 # define BOOST_FUSION_NOEXCEPT_ON_DEFAULTED BOOST_NOEXCEPT