| 1 | ////////////////////////////////////////////////////////////////////////////// |
| 2 | // |
| 3 | // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost |
| 4 | // Software License, Version 1.0. (See accompanying file |
| 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | // |
| 7 | // See http://www.boost.org/libs/interprocess for documentation. |
| 8 | // |
| 9 | ////////////////////////////////////////////////////////////////////////////// |
| 10 | |
| 11 | #ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP |
| 12 | #define BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP |
| 13 | |
| 14 | #ifndef BOOST_CONFIG_HPP |
| 15 | # include <boost/config.hpp> |
| 16 | #endif |
| 17 | |
| 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) |
| 19 | # pragma once |
| 20 | #endif |
| 21 | |
| 22 | #ifndef BOOST_CONFIG_HPP |
| 23 | #include <boost/config.hpp> |
| 24 | #endif |
| 25 | |
| 26 | // MSVC-12 ICEs when variadic templates are enabled. |
| 27 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && (!defined(BOOST_MSVC) || BOOST_MSVC >= 1900) |
| 28 | #define BOOST_INTRUSIVE_VARIADIC_TEMPLATES |
| 29 | #endif |
| 30 | |
| 31 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 32 | #define BOOST_INTRUSIVE_PERFECT_FORWARDING |
| 33 | #endif |
| 34 | |
| 35 | //Macros for documentation purposes. For code, expands to the argument |
| 36 | #define BOOST_INTRUSIVE_IMPDEF(TYPE) TYPE |
| 37 | #define BOOST_INTRUSIVE_SEEDOC(TYPE) TYPE |
| 38 | #define BOOST_INTRUSIVE_DOC1ST(TYPE1, TYPE2) TYPE2 |
| 39 | #define BOOST_INTRUSIVE_I , |
| 40 | #define BOOST_INTRUSIVE_DOCIGN(T1) T1 |
| 41 | |
| 42 | //#define BOOST_INTRUSIVE_DISABLE_FORCEINLINE |
| 43 | |
| 44 | #if defined(BOOST_INTRUSIVE_DISABLE_FORCEINLINE) |
| 45 | #define BOOST_INTRUSIVE_FORCEINLINE inline |
| 46 | #elif defined(BOOST_INTRUSIVE_FORCEINLINE_IS_BOOST_FORCELINE) |
| 47 | #define BOOST_INTRUSIVE_FORCEINLINE BOOST_FORCEINLINE |
| 48 | #elif defined(BOOST_MSVC) && (_MSC_VER < 1900 || defined(_DEBUG)) |
| 49 | //"__forceinline" and MSVC seems to have some bugs in old versions and in debug mode |
| 50 | #define BOOST_INTRUSIVE_FORCEINLINE inline |
| 51 | #elif defined(BOOST_CLANG) || (defined(BOOST_GCC) && ((__GNUC__ <= 5) || defined(__MINGW32__))) |
| 52 | //Older GCCs have problems with forceinline |
| 53 | //Clang can have code bloat issues with forceinline, see |
| 54 | //https://lists.boost.org/boost-users/2023/04/91445.php and |
| 55 | //https://github.com/llvm/llvm-project/issues/62202 |
| 56 | #define BOOST_INTRUSIVE_FORCEINLINE inline |
| 57 | #else |
| 58 | #define BOOST_INTRUSIVE_FORCEINLINE BOOST_FORCEINLINE |
| 59 | #endif |
| 60 | |
| 61 | #if !(defined BOOST_NO_EXCEPTIONS) |
| 62 | # define BOOST_INTRUSIVE_TRY { try |
| 63 | # define BOOST_INTRUSIVE_CATCH(x) catch(x) |
| 64 | # define BOOST_INTRUSIVE_RETHROW throw; |
| 65 | # define BOOST_INTRUSIVE_CATCH_END } |
| 66 | #else |
| 67 | # if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900 |
| 68 | # define BOOST_INTRUSIVE_TRY { if (true) |
| 69 | # define BOOST_INTRUSIVE_CATCH(x) else if (false) |
| 70 | # else |
| 71 | // warning C4127: conditional expression is constant |
| 72 | # define BOOST_INTRUSIVE_TRY { \ |
| 73 | __pragma(warning(push)) \ |
| 74 | __pragma(warning(disable: 4127)) \ |
| 75 | if (true) \ |
| 76 | __pragma(warning(pop)) |
| 77 | # define BOOST_INTRUSIVE_CATCH(x) else \ |
| 78 | __pragma(warning(push)) \ |
| 79 | __pragma(warning(disable: 4127)) \ |
| 80 | if (false) \ |
| 81 | __pragma(warning(pop)) |
| 82 | # endif |
| 83 | # define BOOST_INTRUSIVE_RETHROW |
| 84 | # define BOOST_INTRUSIVE_CATCH_END } |
| 85 | #endif |
| 86 | |
| 87 | #ifndef BOOST_NO_CXX11_STATIC_ASSERT |
| 88 | # ifndef BOOST_NO_CXX11_VARIADIC_MACROS |
| 89 | # define BOOST_INTRUSIVE_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__) |
| 90 | # else |
| 91 | # define BOOST_INTRUSIVE_STATIC_ASSERT( B ) static_assert(B, #B) |
| 92 | # endif |
| 93 | #else |
| 94 | namespace boost { |
| 95 | namespace intrusive { |
| 96 | namespace detail { |
| 97 | |
| 98 | template<bool B> |
| 99 | struct STATIC_ASSERTION_FAILURE; |
| 100 | |
| 101 | template<> |
| 102 | struct STATIC_ASSERTION_FAILURE<true>{}; |
| 103 | |
| 104 | template<unsigned> struct static_assert_test {}; |
| 105 | |
| 106 | }}} |
| 107 | |
| 108 | #define BOOST_INTRUSIVE_STATIC_ASSERT(B) \ |
| 109 | typedef ::boost::intrusive::detail::static_assert_test<\ |
| 110 | (unsigned)sizeof(::boost::intrusive::detail::STATIC_ASSERTION_FAILURE<bool(B)>)>\ |
| 111 | BOOST_JOIN(boost_intrusive_static_assert_typedef_, __LINE__) BOOST_ATTRIBUTE_UNUSED |
| 112 | |
| 113 | #endif |
| 114 | |
| 115 | #endif //#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP |
| 116 | |