| 1 | |
| 2 | // Copyright (C) 2008-2016 Daniel James. |
| 3 | // Copyright (C) 2022 Christian Mazakas |
| 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 | #ifndef BOOST_UNORDERED_FWD_HPP_INCLUDED |
| 8 | #define BOOST_UNORDERED_FWD_HPP_INCLUDED |
| 9 | |
| 10 | #include <boost/config.hpp> |
| 11 | #if defined(BOOST_HAS_PRAGMA_ONCE) |
| 12 | #pragma once |
| 13 | #endif |
| 14 | |
| 15 | #include <boost/predef.h> |
| 16 | |
| 17 | #if defined(BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT) |
| 18 | // Already defined. |
| 19 | #elif defined(BOOST_LIBSTDCXX11) |
| 20 | // https://github.com/gcc-mirror/gcc/blob/gcc-4_6-branch/libstdc++-v3/include/bits/stl_pair.h#L70 |
| 21 | #if BOOST_LIBSTDCXX_VERSION > 40600 |
| 22 | #define BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT 1 |
| 23 | #endif |
| 24 | #elif BOOST_LIB_STD_CXX |
| 25 | // https://github.com/llvm-mirror/libcxx/blob/release_30/include/utility#L206 |
| 26 | #if BOOST_LIB_STD_CXX >= BOOST_VERSION_NUMBER(3, 0, 0) |
| 27 | #define BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT 1 |
| 28 | #endif |
| 29 | #elif defined(BOOST_LIB_STD_DINKUMWARE) |
| 30 | // Apparently C++11 standard supported in Visual Studio 2012 |
| 31 | // https://msdn.microsoft.com/en-us/library/hh567368.aspx#stl |
| 32 | // 2012 = VC+11 = BOOST_MSVC 1700 Hopefully! |
| 33 | // I have no idea when Dinkumware added it, probably a lot |
| 34 | // earlier than this check. |
| 35 | #if BOOST_LIB_STD_DINKUMWARE >= BOOST_VERSION_NUMBER(6, 10, 0) || \ |
| 36 | BOOST_COMP_MSVC >= BOOST_VERSION_NUMBER(17, 0, 0) |
| 37 | #define BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT 1 |
| 38 | #endif |
| 39 | #endif |
| 40 | |
| 41 | // Assume that an unknown library does not support piecewise construction. |
| 42 | #if !defined(BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT) |
| 43 | #define BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT 0 |
| 44 | #endif |
| 45 | |
| 46 | #if BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT |
| 47 | #include <utility> |
| 48 | #endif |
| 49 | |
| 50 | namespace boost { |
| 51 | namespace unordered { |
| 52 | #if BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT |
| 53 | using std::piecewise_construct_t; |
| 54 | using std::piecewise_construct; |
| 55 | #else |
| 56 | struct piecewise_construct_t |
| 57 | { |
| 58 | }; |
| 59 | const piecewise_construct_t piecewise_construct = piecewise_construct_t(); |
| 60 | #endif |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // BOOST_UNORDERED_EMPLACE_LIMIT = The maximum number of parameters in |
| 65 | // emplace (not including things like hints). Don't set it to a lower value, as |
| 66 | // that might break something. |
| 67 | |
| 68 | #if !defined BOOST_UNORDERED_EMPLACE_LIMIT |
| 69 | #define BOOST_UNORDERED_EMPLACE_LIMIT 10 |
| 70 | #endif |
| 71 | |
| 72 | //////////////////////////////////////////////////////////////////////////////// |
| 73 | // Configuration |
| 74 | // |
| 75 | // Unless documented elsewhere these configuration macros should be considered |
| 76 | // an implementation detail, I'll try not to break them, but you never know. |
| 77 | |
| 78 | // Use Sun C++ workarounds |
| 79 | // I'm not sure which versions of the compiler require these workarounds, so |
| 80 | // I'm just using them of everything older than the current test compilers |
| 81 | // (as of May 2017). |
| 82 | |
| 83 | #if !defined(BOOST_UNORDERED_SUN_WORKAROUNDS1) |
| 84 | #if BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 20, 0) |
| 85 | #define BOOST_UNORDERED_SUN_WORKAROUNDS1 1 |
| 86 | #else |
| 87 | #define BOOST_UNORDERED_SUN_WORKAROUNDS1 0 |
| 88 | #endif |
| 89 | #endif |
| 90 | |
| 91 | // BOOST_UNORDERED_TUPLE_ARGS |
| 92 | // |
| 93 | // Maximum number of std::tuple members to support, or 0 if std::tuple |
| 94 | // isn't avaiable. More are supported when full C++11 is used. |
| 95 | |
| 96 | // Already defined, so do nothing |
| 97 | #if defined(BOOST_UNORDERED_TUPLE_ARGS) |
| 98 | |
| 99 | // Assume if we have C++11 tuple it's properly variadic, |
| 100 | // and just use a max number of 10 arguments. |
| 101 | #elif !defined(BOOST_NO_CXX11_HDR_TUPLE) |
| 102 | #define BOOST_UNORDERED_TUPLE_ARGS 10 |
| 103 | |
| 104 | // Visual C++ has a decent enough tuple for piecewise construction, |
| 105 | // so use that if available, using _VARIADIC_MAX for the maximum |
| 106 | // number of parameters. Note that this comes after the check |
| 107 | // for a full C++11 tuple. |
| 108 | #elif defined(BOOST_MSVC) |
| 109 | #if !BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT |
| 110 | #define BOOST_UNORDERED_TUPLE_ARGS 0 |
| 111 | #elif defined(_VARIADIC_MAX) |
| 112 | #define BOOST_UNORDERED_TUPLE_ARGS _VARIADIC_MAX |
| 113 | #else |
| 114 | #define BOOST_UNORDERED_TUPLE_ARGS 5 |
| 115 | #endif |
| 116 | |
| 117 | // Assume that we don't have std::tuple |
| 118 | #else |
| 119 | #define BOOST_UNORDERED_TUPLE_ARGS 0 |
| 120 | #endif |
| 121 | |
| 122 | #if BOOST_UNORDERED_TUPLE_ARGS |
| 123 | #include <tuple> |
| 124 | #endif |
| 125 | |
| 126 | // BOOST_UNORDERED_CXX11_CONSTRUCTION |
| 127 | // |
| 128 | // Use C++11 construction, requires variadic arguments, good construct support |
| 129 | // in allocator_traits and piecewise construction of std::pair |
| 130 | // Otherwise allocators aren't used for construction/destruction |
| 131 | |
| 132 | #if BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT && \ |
| 133 | !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && BOOST_UNORDERED_TUPLE_ARGS |
| 134 | #if BOOST_COMP_SUNPRO && BOOST_LIB_STD_GNU |
| 135 | // Sun C++ std::pair piecewise construction doesn't seem to be exception safe. |
| 136 | // (At least for Sun C++ 12.5 using libstdc++). |
| 137 | #define BOOST_UNORDERED_CXX11_CONSTRUCTION 0 |
| 138 | #elif BOOST_COMP_GNUC && BOOST_COMP_GNUC < BOOST_VERSION_NUMBER(4, 7, 0) |
| 139 | // Piecewise construction in GCC 4.6 doesn't work for uncopyable types. |
| 140 | #define BOOST_UNORDERED_CXX11_CONSTRUCTION 0 |
| 141 | #elif !defined(BOOST_NO_CXX11_ALLOCATOR) |
| 142 | #define BOOST_UNORDERED_CXX11_CONSTRUCTION 1 |
| 143 | #endif |
| 144 | #endif |
| 145 | |
| 146 | #if !defined(BOOST_UNORDERED_CXX11_CONSTRUCTION) |
| 147 | #define BOOST_UNORDERED_CXX11_CONSTRUCTION 0 |
| 148 | #endif |
| 149 | |
| 150 | #endif |
| 151 | |