| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard.
 | 
					
						
							|  |  |  | // Copyright (C) 2005-2016 Daniel James
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | // Copyright (C) 2022 Joaquin M Lopez Munoz.
 | 
					
						
							|  |  |  | // Copyright (C) 2022 Christian Mazakas
 | 
					
						
							| 
									
										
										
										
											2017-04-04 22:04:07 +01:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Distributed under the Boost Software License, Version 1.0. (See accompanying
 | 
					
						
							|  |  |  | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef BOOST_UNORDERED_DETAIL_IMPLEMENTATION_HPP
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_DETAIL_IMPLEMENTATION_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/config.hpp>
 | 
					
						
							|  |  |  | #if defined(BOOST_HAS_PRAGMA_ONCE)
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/assert.hpp>
 | 
					
						
							| 
									
										
										
										
											2021-12-07 08:35:56 -08:00
										 |  |  | #include <boost/core/allocator_traits.hpp>
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | #include <boost/core/bit.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-12-03 14:11:34 +00:00
										 |  |  | #include <boost/core/no_exceptions_support.hpp>
 | 
					
						
							| 
									
										
										
										
											2018-01-26 18:59:11 +00:00
										 |  |  | #include <boost/core/pointer_traits.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/limits.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/move/move.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #include <boost/preprocessor/arithmetic/inc.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/preprocessor/cat.hpp>
 | 
					
						
							|  |  |  | #include <boost/preprocessor/repetition/enum.hpp>
 | 
					
						
							|  |  |  | #include <boost/preprocessor/repetition/enum_binary_params.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/preprocessor/repetition/enum_params.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/preprocessor/repetition/repeat_from_to.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/preprocessor/seq/enum.hpp>
 | 
					
						
							|  |  |  | #include <boost/preprocessor/seq/size.hpp>
 | 
					
						
							|  |  |  | #include <boost/swap.hpp>
 | 
					
						
							|  |  |  | #include <boost/throw_exception.hpp>
 | 
					
						
							|  |  |  | #include <boost/tuple/tuple.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/type_traits/add_lvalue_reference.hpp>
 | 
					
						
							|  |  |  | #include <boost/type_traits/aligned_storage.hpp>
 | 
					
						
							|  |  |  | #include <boost/type_traits/alignment_of.hpp>
 | 
					
						
							| 
									
										
										
										
											2018-01-05 17:48:13 +00:00
										 |  |  | #include <boost/type_traits/integral_constant.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-12-03 18:45:00 +00:00
										 |  |  | #include <boost/type_traits/is_base_of.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/type_traits/is_class.hpp>
 | 
					
						
							| 
									
										
										
										
											2021-12-21 09:21:51 -08:00
										 |  |  | #include <boost/type_traits/is_convertible.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/type_traits/is_empty.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/type_traits/is_nothrow_move_assignable.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/type_traits/is_nothrow_move_constructible.hpp>
 | 
					
						
							| 
									
										
										
										
											2018-01-27 09:38:19 +00:00
										 |  |  | #include <boost/type_traits/is_nothrow_swappable.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | #include <boost/type_traits/is_same.hpp>
 | 
					
						
							| 
									
										
										
										
											2021-11-22 11:16:04 -08:00
										 |  |  | #include <boost/type_traits/make_void.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | #include <boost/type_traits/remove_const.hpp>
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | #include <boost/unordered/detail/fca.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/unordered/detail/fwd.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/utility/addressof.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <boost/utility/enable_if.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <cmath>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <iterator>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <stdexcept>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #include <utility>
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 20:14:26 +00:00
										 |  |  | #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
 | 
					
						
							|  |  |  | #include <type_traits>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Configuration
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Unless documented elsewhere these configuration macros should be considered
 | 
					
						
							|  |  |  | // an implementation detail, I'll try not to break them, but you never know.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 18:23:23 +01:00
										 |  |  | // Use Sun C++ workarounds
 | 
					
						
							|  |  |  | // I'm not sure which versions of the compiler require these workarounds, so
 | 
					
						
							|  |  |  | // I'm just using them of everything older than the current test compilers
 | 
					
						
							|  |  |  | // (as of May 2017).
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if !defined(BOOST_UNORDERED_SUN_WORKAROUNDS1)
 | 
					
						
							| 
									
										
										
										
											2017-05-25 08:53:34 +01:00
										 |  |  | #if BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 20, 0)
 | 
					
						
							| 
									
										
										
										
											2017-05-16 18:23:23 +01:00
										 |  |  | #define BOOST_UNORDERED_SUN_WORKAROUNDS1 1
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_SUN_WORKAROUNDS1 0
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 09:44:56 +01:00
										 |  |  | // BOOST_UNORDERED_EMPLACE_LIMIT = The maximum number of parameters in
 | 
					
						
							| 
									
										
										
										
											2017-04-19 09:46:15 +01:00
										 |  |  | // emplace (not including things like hints). Don't set it to a lower value, as
 | 
					
						
							|  |  |  | // that might break something.
 | 
					
						
							| 
									
										
										
										
											2017-02-23 20:14:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if !defined BOOST_UNORDERED_EMPLACE_LIMIT
 | 
					
						
							| 
									
										
										
										
											2017-04-23 09:44:56 +01:00
										 |  |  | #define BOOST_UNORDERED_EMPLACE_LIMIT 10
 | 
					
						
							| 
									
										
										
										
											2017-02-23 20:14:26 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:53 +01:00
										 |  |  | // BOOST_UNORDERED_TUPLE_ARGS
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Maximum number of std::tuple members to support, or 0 if std::tuple
 | 
					
						
							|  |  |  | // isn't avaiable. More are supported when full C++11 is used.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Already defined, so do nothing
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #if defined(BOOST_UNORDERED_TUPLE_ARGS)
 | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Assume if we have C++11 tuple it's properly variadic,
 | 
					
						
							|  |  |  | // and just use a max number of 10 arguments.
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #elif !defined(BOOST_NO_CXX11_HDR_TUPLE)
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_TUPLE_ARGS 10
 | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Visual C++ has a decent enough tuple for piecewise construction,
 | 
					
						
							|  |  |  | // so use that if available, using _VARIADIC_MAX for the maximum
 | 
					
						
							|  |  |  | // number of parameters. Note that this comes after the check
 | 
					
						
							|  |  |  | // for a full C++11 tuple.
 | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:52 +01:00
										 |  |  | #elif defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #if !BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_TUPLE_ARGS 0
 | 
					
						
							|  |  |  | #elif defined(_VARIADIC_MAX)
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #define BOOST_UNORDERED_TUPLE_ARGS _VARIADIC_MAX
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_TUPLE_ARGS 5
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Assume that we don't have std::tuple
 | 
					
						
							| 
									
										
										
											
												More consistent std::tuple configuration
Was getting a weird test failure for Visual C++ 11,
BOOST_NO_CXX11_HDR_TUPLE is defined, so the code doesn't support
std::tuple, but BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT was also
true, and so there are functions for constructing using
std::piecewise_construct/std::tuple, which don't work.
So, I'm assuming that if BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT is true,
then there must be a std::tuple. I guess it doesn't have full C++11 support,
which is why BOOST_NO_CXX11_HDR_TUPLE is defined, but it appears to be
good enough for us. If not, this will break things.
											
										 
											2017-04-21 20:26:32 +01:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #define BOOST_UNORDERED_TUPLE_ARGS 0
 | 
					
						
							| 
									
										
										
											
												More consistent std::tuple configuration
Was getting a weird test failure for Visual C++ 11,
BOOST_NO_CXX11_HDR_TUPLE is defined, so the code doesn't support
std::tuple, but BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT was also
true, and so there are functions for constructing using
std::piecewise_construct/std::tuple, which don't work.
So, I'm assuming that if BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT is true,
then there must be a std::tuple. I guess it doesn't have full C++11 support,
which is why BOOST_NO_CXX11_HDR_TUPLE is defined, but it appears to be
good enough for us. If not, this will break things.
											
										 
											2017-04-21 20:26:32 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #if BOOST_UNORDERED_TUPLE_ARGS
 | 
					
						
							| 
									
										
										
											
												More consistent std::tuple configuration
Was getting a weird test failure for Visual C++ 11,
BOOST_NO_CXX11_HDR_TUPLE is defined, so the code doesn't support
std::tuple, but BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT was also
true, and so there are functions for constructing using
std::piecewise_construct/std::tuple, which don't work.
So, I'm assuming that if BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT is true,
then there must be a std::tuple. I guess it doesn't have full C++11 support,
which is why BOOST_NO_CXX11_HDR_TUPLE is defined, but it appears to be
good enough for us. If not, this will break things.
											
										 
											2017-04-21 20:26:32 +01:00
										 |  |  | #include <tuple>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 18:15:56 +01:00
										 |  |  | // BOOST_UNORDERED_CXX11_CONSTRUCTION
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Use C++11 construction, requires variadic arguments, good construct support
 | 
					
						
							|  |  |  | // in allocator_traits and piecewise construction of std::pair
 | 
					
						
							|  |  |  | // Otherwise allocators aren't used for construction/destruction
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT &&                                \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && BOOST_UNORDERED_TUPLE_ARGS | 
					
						
							| 
									
										
										
										
											2017-05-16 18:15:56 +01:00
										 |  |  | #if BOOST_COMP_SUNPRO && BOOST_LIB_STD_GNU
 | 
					
						
							|  |  |  | // Sun C++ std::pair piecewise construction doesn't seem to be exception safe.
 | 
					
						
							|  |  |  | // (At least for Sun C++ 12.5 using libstdc++).
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_CXX11_CONSTRUCTION 0
 | 
					
						
							| 
									
										
										
										
											2017-05-19 17:24:44 +01:00
										 |  |  | #elif BOOST_COMP_GNUC && BOOST_COMP_GNUC < BOOST_VERSION_NUMBER(4, 7, 0)
 | 
					
						
							|  |  |  | // Piecewise construction in GCC 4.6 doesn't work for uncopyable types.
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_CXX11_CONSTRUCTION 0
 | 
					
						
							| 
									
										
										
										
											2021-12-08 10:06:01 -08:00
										 |  |  | #elif !defined(BOOST_NO_CXX11_ALLOCATOR)
 | 
					
						
							| 
									
										
										
										
											2017-05-16 18:15:56 +01:00
										 |  |  | #define BOOST_UNORDERED_CXX11_CONSTRUCTION 1
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if !defined(BOOST_UNORDERED_CXX11_CONSTRUCTION)
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_CXX11_CONSTRUCTION 0
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | #if BOOST_UNORDERED_CXX11_CONSTRUCTION
 | 
					
						
							|  |  |  | #include <boost/mp11/list.hpp>
 | 
					
						
							|  |  |  | #include <boost/mp11/algorithm.hpp>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:53 +01:00
										 |  |  | // BOOST_UNORDERED_SUPPRESS_DEPRECATED
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Define to stop deprecation attributes
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-15 17:35:09 +01:00
										 |  |  | #if defined(BOOST_UNORDERED_SUPPRESS_DEPRECATED)
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_DEPRECATED(msg)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:53 +01:00
										 |  |  | // BOOST_UNORDERED_DEPRECATED
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Wrapper around various depreaction attributes.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-15 17:35:09 +01:00
										 |  |  | #if defined(__has_cpp_attribute) &&                                            \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   (!defined(__cplusplus) || __cplusplus >= 201402) | 
					
						
							| 
									
										
										
										
											2017-04-15 17:35:09 +01:00
										 |  |  | #if __has_cpp_attribute(deprecated) && !defined(BOOST_UNORDERED_DEPRECATED)
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_DEPRECATED(msg) [[deprecated(msg)]]
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if !defined(BOOST_UNORDERED_DEPRECATED)
 | 
					
						
							|  |  |  | #if defined(__GNUC__) && __GNUC__ >= 4
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_DEPRECATED(msg) __attribute__((deprecated))
 | 
					
						
							|  |  |  | #elif defined(_MSC_VER) && _MSC_VER >= 1400
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_DEPRECATED(msg) __declspec(deprecated(msg))
 | 
					
						
							|  |  |  | #elif defined(_MSC_VER) && _MSC_VER >= 1310
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_DEPRECATED(msg) __declspec(deprecated)
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_DEPRECATED(msg)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-19 12:11:36 +00:00
										 |  |  | // BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES)
 | 
					
						
							|  |  |  | #if BOOST_COMP_CLANG && __cplusplus >= 201703
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 1
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES)
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 0
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | namespace boost { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename Types> struct table; | 
					
						
							| 
									
										
										
										
											2017-02-23 20:14:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       static const float minimum_max_load_factor = 1e-3f; | 
					
						
							|  |  |  |       static const std::size_t default_bucket_count = 11; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       struct move_tag | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       struct empty_emplace | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       struct no_key | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         no_key() {} | 
					
						
							|  |  |  |         template <class T> no_key(T const&) {} | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       namespace func { | 
					
						
							|  |  |  |         template <class T> inline void ignore_unused_variable_warning(T const&) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       // iterator SFINAE
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename I> | 
					
						
							| 
									
										
										
										
											2017-12-03 18:45:00 +00:00
										 |  |  |       struct is_forward : boost::is_base_of<std::forward_iterator_tag, | 
					
						
							|  |  |  |                             typename std::iterator_traits<I>::iterator_category> | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename I, typename ReturnType> | 
					
						
							|  |  |  |       struct enable_if_forward | 
					
						
							|  |  |  |         : boost::enable_if_c<boost::unordered::detail::is_forward<I>::value, | 
					
						
							|  |  |  |             ReturnType> | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename I, typename ReturnType> | 
					
						
							|  |  |  |       struct disable_if_forward | 
					
						
							|  |  |  |         : boost::disable_if_c<boost::unordered::detail::is_forward<I>::value, | 
					
						
							|  |  |  |             ReturnType> | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       // insert_size/initial_size
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <class I> | 
					
						
							| 
									
										
										
										
											2021-11-18 12:54:17 -08:00
										 |  |  |       inline typename boost::unordered::detail::enable_if_forward<I, | 
					
						
							|  |  |  |         std::size_t>::type | 
					
						
							|  |  |  |       insert_size(I i, I j) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							|  |  |  |         return static_cast<std::size_t>(std::distance(i, j)); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <class I> | 
					
						
							| 
									
										
										
										
											2021-11-18 12:54:17 -08:00
										 |  |  |       inline typename boost::unordered::detail::disable_if_forward<I, | 
					
						
							|  |  |  |         std::size_t>::type insert_size(I, I) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							|  |  |  |         return 1; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <class I> | 
					
						
							| 
									
										
										
										
											2017-10-05 10:54:22 +01:00
										 |  |  |       inline std::size_t initial_size(I i, I j, | 
					
						
							|  |  |  |         std::size_t num_buckets = | 
					
						
							|  |  |  |           boost::unordered::detail::default_bucket_count) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							|  |  |  |         return (std::max)( | 
					
						
							| 
									
										
										
										
											2017-10-05 10:54:22 +01:00
										 |  |  |           boost::unordered::detail::insert_size(i, j), num_buckets); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       // compressed
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       template <typename T, int Index> | 
					
						
							|  |  |  |       struct compressed_base : boost::empty_value<T> | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         compressed_base(T const& x) : empty_value<T>(boost::empty_init_t(), x) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         compressed_base(T& x, move_tag) | 
					
						
							|  |  |  |             : empty_value<T>(boost::empty_init_t(), boost::move(x)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-10-05 10:54:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         T& get() { return empty_value<T>::get(); } | 
					
						
							|  |  |  |         T const& get() const { return empty_value<T>::get(); } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename T, int Index> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       struct generate_base : boost::unordered::detail::compressed_base<T, Index> | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         typedef compressed_base<T, Index> type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         generate_base() : type() {} | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename T1, typename T2> | 
					
						
							|  |  |  |       struct compressed | 
					
						
							|  |  |  |         : private boost::unordered::detail::generate_base<T1, 1>::type, | 
					
						
							|  |  |  |           private boost::unordered::detail::generate_base<T2, 2>::type | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef typename generate_base<T1, 1>::type base1; | 
					
						
							|  |  |  |         typedef typename generate_base<T2, 2>::type base2; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         typedef T1 first_type; | 
					
						
							|  |  |  |         typedef T2 second_type; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         first_type& first() { return static_cast<base1*>(this)->get(); } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         first_type const& first() const | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return static_cast<base1 const*>(this)->get(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         second_type& second() { return static_cast<base2*>(this)->get(); } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         second_type const& second() const | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return static_cast<base2 const*>(this)->get(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename First, typename Second> | 
					
						
							|  |  |  |         compressed(First const& x1, Second const& x2) : base1(x1), base2(x2) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         compressed(compressed const& x) : base1(x.first()), base2(x.second()) {} | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         compressed(compressed& x, move_tag m) | 
					
						
							|  |  |  |             : base1(x.first(), m), base2(x.second(), m) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void assign(compressed const& x) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           first() = x.first(); | 
					
						
							|  |  |  |           second() = x.second(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void move_assign(compressed& x) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           first() = boost::move(x.first()); | 
					
						
							|  |  |  |           second() = boost::move(x.second()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-23 20:14:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void swap(compressed& x) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           boost::swap(first(), x.first()); | 
					
						
							|  |  |  |           boost::swap(second(), x.second()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-23 20:14:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       private: | 
					
						
							|  |  |  |         // Prevent assignment just to make use of assign or
 | 
					
						
							|  |  |  |         // move_assign explicit.
 | 
					
						
							|  |  |  |         compressed& operator=(compressed const&); | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       // pair_traits
 | 
					
						
							|  |  |  |       //
 | 
					
						
							|  |  |  |       // Used to get the types from a pair without instantiating it.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename Pair> struct pair_traits | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef typename Pair::first_type first_type; | 
					
						
							|  |  |  |         typedef typename Pair::second_type second_type; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename T1, typename T2> struct pair_traits<std::pair<T1, T2> > | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef T1 first_type; | 
					
						
							|  |  |  |         typedef T2 second_type; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-23 20:14:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #if defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #pragma warning(push)
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #pragma warning(disable : 4512) // assignment operator could not be generated.
 | 
					
						
							|  |  |  | #pragma warning(disable : 4345) // behavior change: an object of POD type
 | 
					
						
							|  |  |  | // constructed with an initializer of the form ()
 | 
					
						
							|  |  |  | // will be default-initialized.
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       // Bits and pieces for implementing traits
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename T> | 
					
						
							|  |  |  |       typename boost::add_lvalue_reference<T>::type make(); | 
					
						
							|  |  |  |       struct choice9 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[9]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       struct choice8 : choice9 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[8]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       struct choice7 : choice8 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[7]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       struct choice6 : choice7 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[6]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       struct choice5 : choice6 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[5]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       struct choice4 : choice5 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[4]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       struct choice3 : choice4 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[3]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       struct choice2 : choice3 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[2]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       struct choice1 : choice2 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef char (&type)[1]; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       choice1 choose(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       typedef choice1::type yes_type; | 
					
						
							|  |  |  |       typedef choice2::type no_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       struct private_type | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         private_type const& operator,(int) const; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename T> no_type is_private_type(T const&); | 
					
						
							|  |  |  |       yes_type is_private_type(private_type const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       struct convert_from_anything | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         template <typename T> convert_from_anything(T const&); | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-06-04 08:46:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | ////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // emplace_args
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Either forwarding variadic arguments, or storing the arguments in
 | 
					
						
							|  |  |  | // emplace_args##n
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_EMPLACE_TEMPLATE typename... Args
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_EMPLACE_ARGS BOOST_FWD_REF(Args)... args
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_EMPLACE_FORWARD boost::forward<Args>(args)...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_EMPLACE_TEMPLATE typename Args
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_EMPLACE_ARGS Args const& args
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_EMPLACE_FORWARD args
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #define BOOST_UNORDERED_EARGS_MEMBER(z, n, _)                                  \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   typedef BOOST_FWD_REF(BOOST_PP_CAT(A, n)) BOOST_PP_CAT(Arg, n);              \ | 
					
						
							|  |  |  |   BOOST_PP_CAT(Arg, n) BOOST_PP_CAT(a, n); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #define BOOST_UNORDERED_EARGS_MEMBER(z, n, _)                                  \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   typedef typename boost::add_lvalue_reference<BOOST_PP_CAT(A, n)>::type       \ | 
					
						
							|  |  |  |     BOOST_PP_CAT(Arg, n);                                                      \ | 
					
						
							|  |  |  |   BOOST_PP_CAT(Arg, n) BOOST_PP_CAT(a, n); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | #define BOOST_UNORDERED_FWD_PARAM(z, n, a)                                     \
 | 
					
						
							|  |  |  |   BOOST_FWD_REF(BOOST_PP_CAT(A, n)) BOOST_PP_CAT(a, n) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_CALL_FORWARD(z, i, a)                                  \
 | 
					
						
							|  |  |  |   boost::forward<BOOST_PP_CAT(A, i)>(BOOST_PP_CAT(a, i)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_EARGS_INIT(z, n, _)                                    \
 | 
					
						
							|  |  |  |   BOOST_PP_CAT(a, n)(BOOST_PP_CAT(b, n)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_EARGS(z, n, _)                                         \
 | 
					
						
							|  |  |  |   template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)>                          \ | 
					
						
							|  |  |  |   struct BOOST_PP_CAT(emplace_args, n)                                         \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     BOOST_PP_REPEAT_##z(n, BOOST_UNORDERED_EARGS_MEMBER, _) BOOST_PP_CAT(      \ | 
					
						
							|  |  |  |       emplace_args, n)(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, Arg, b))            \ | 
					
						
							|  |  |  |         : BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_EARGS_INIT, _)                  \ | 
					
						
							|  |  |  |     {                                                                          \ | 
					
						
							|  |  |  |     }                                                                          \ | 
					
						
							|  |  |  |   };                                                                           \ | 
					
						
							|  |  |  |                                                                                \ | 
					
						
							|  |  |  |   template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)>                          \ | 
					
						
							|  |  |  |   inline BOOST_PP_CAT(emplace_args, n)<BOOST_PP_ENUM_PARAMS_Z(z, n, A)>        \ | 
					
						
							|  |  |  |     create_emplace_args(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, b))    \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     BOOST_PP_CAT(emplace_args, n)<BOOST_PP_ENUM_PARAMS_Z(z, n, A)> e(          \ | 
					
						
							|  |  |  |       BOOST_PP_ENUM_PARAMS_Z(z, n, b));                                        \ | 
					
						
							|  |  |  |     return e;                                                                  \ | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename A0> struct emplace_args1 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         BOOST_UNORDERED_EARGS_MEMBER(1, 0, _) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         explicit emplace_args1(Arg0 b0) : a0(b0) {} | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename A0> | 
					
						
							|  |  |  |       inline emplace_args1<A0> create_emplace_args(BOOST_FWD_REF(A0) b0) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emplace_args1<A0> e(b0); | 
					
						
							|  |  |  |         return e; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename A0, typename A1> struct emplace_args2 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         BOOST_UNORDERED_EARGS_MEMBER(1, 0, _) | 
					
						
							|  |  |  |         BOOST_UNORDERED_EARGS_MEMBER(1, 1, _) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         emplace_args2(Arg0 b0, Arg1 b1) : a0(b0), a1(b1) {} | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename A0, typename A1> | 
					
						
							|  |  |  |       inline emplace_args2<A0, A1> create_emplace_args( | 
					
						
							|  |  |  |         BOOST_FWD_REF(A0) b0, BOOST_FWD_REF(A1) b1) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emplace_args2<A0, A1> e(b0, b1); | 
					
						
							|  |  |  |         return e; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename A0, typename A1, typename A2> struct emplace_args3 | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         BOOST_UNORDERED_EARGS_MEMBER(1, 0, _) | 
					
						
							|  |  |  |         BOOST_UNORDERED_EARGS_MEMBER(1, 1, _) | 
					
						
							|  |  |  |         BOOST_UNORDERED_EARGS_MEMBER(1, 2, _) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         emplace_args3(Arg0 b0, Arg1 b1, Arg2 b2) : a0(b0), a1(b1), a2(b2) {} | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename A0, typename A1, typename A2> | 
					
						
							|  |  |  |       inline emplace_args3<A0, A1, A2> create_emplace_args( | 
					
						
							|  |  |  |         BOOST_FWD_REF(A0) b0, BOOST_FWD_REF(A1) b1, BOOST_FWD_REF(A2) b2) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emplace_args3<A0, A1, A2> e(b0, b1, b2); | 
					
						
							|  |  |  |         return e; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       BOOST_UNORDERED_EARGS(1, 4, _) | 
					
						
							|  |  |  |       BOOST_UNORDERED_EARGS(1, 5, _) | 
					
						
							|  |  |  |       BOOST_UNORDERED_EARGS(1, 6, _) | 
					
						
							|  |  |  |       BOOST_UNORDERED_EARGS(1, 7, _) | 
					
						
							|  |  |  |       BOOST_UNORDERED_EARGS(1, 8, _) | 
					
						
							|  |  |  |       BOOST_UNORDERED_EARGS(1, 9, _) | 
					
						
							|  |  |  |       BOOST_PP_REPEAT_FROM_TO(10, BOOST_PP_INC(BOOST_UNORDERED_EMPLACE_LIMIT), | 
					
						
							|  |  |  |         BOOST_UNORDERED_EARGS, _) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_DEFINE_EMPLACE_ARGS
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_EARGS_MEMBER
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_EARGS_INIT
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Some utilities for implementing allocator_traits, but useful elsewhere so
 | 
					
						
							|  |  |  | // they're always defined.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | ////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Integral_constrant, true_type, false_type
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Uses the standard versions if available.
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       using std::integral_constant; | 
					
						
							|  |  |  |       using std::true_type; | 
					
						
							|  |  |  |       using std::false_type; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename T, T Value> struct integral_constant | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         enum | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           value = Value | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       typedef boost::unordered::detail::integral_constant<bool, true> true_type; | 
					
						
							|  |  |  |       typedef boost::unordered::detail::integral_constant<bool, false> | 
					
						
							|  |  |  |         false_type; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 11:16:04 -08:00
										 |  |  | ////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Type checkers used for the transparent member functions added by C++20 and up
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-17 09:47:12 -08:00
										 |  |  |       template <class, class = void> struct is_transparent : public false_type | 
					
						
							| 
									
										
										
										
											2021-11-22 11:16:04 -08:00
										 |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-17 09:47:12 -08:00
										 |  |  |       template <class T> | 
					
						
							|  |  |  |       struct is_transparent<T, | 
					
						
							| 
									
										
										
										
											2021-11-22 13:29:41 -08:00
										 |  |  |         typename boost::make_void<typename T::is_transparent>::type> | 
					
						
							|  |  |  |           : public true_type | 
					
						
							| 
									
										
										
										
											2021-11-22 11:16:04 -08:00
										 |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-17 09:47:12 -08:00
										 |  |  |       template <class, class A, class B> struct are_transparent | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         static bool const value = | 
					
						
							|  |  |  |           is_transparent<A>::value && is_transparent<B>::value; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 09:21:51 -08:00
										 |  |  |       template <class Key, class UnorderedMap> struct transparent_non_iterable | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef typename UnorderedMap::hasher hash; | 
					
						
							|  |  |  |         typedef typename UnorderedMap::key_equal key_equal; | 
					
						
							|  |  |  |         typedef typename UnorderedMap::iterator iterator; | 
					
						
							|  |  |  |         typedef typename UnorderedMap::const_iterator const_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static bool const value = | 
					
						
							|  |  |  |           are_transparent<Key, hash, key_equal>::value && | 
					
						
							|  |  |  |           !boost::is_convertible<Key, iterator>::value && | 
					
						
							|  |  |  |           !boost::is_convertible<Key, const_iterator>::value; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | ////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Explicitly call a destructor
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #pragma warning(push)
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #pragma warning(disable : 4100) // unreferenced formal parameter
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       namespace func { | 
					
						
							|  |  |  |         template <class T> inline void destroy(T* x) { x->~T(); } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #pragma warning(pop)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-01-03 20:55:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |       // value_base
 | 
					
						
							|  |  |  |       //
 | 
					
						
							|  |  |  |       // Space used to store values.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename ValueType> struct value_base | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef ValueType value_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typename boost::aligned_storage<sizeof(value_type), | 
					
						
							|  |  |  |           boost::alignment_of<value_type>::value>::type data_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         value_base() : data_() {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         void* address() { return this; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         value_type& value() { return *(ValueType*)this; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         value_type const& value() const { return *(ValueType const*)this; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         value_type* value_ptr() { return (ValueType*)this; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         value_type const* value_ptr() const { return (ValueType const*)this; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       private: | 
					
						
							|  |  |  |         value_base& operator=(value_base const&); | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |       // optional
 | 
					
						
							|  |  |  |       // TODO: Use std::optional when available.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename T> class optional | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2018-01-10 09:58:08 +00:00
										 |  |  |         BOOST_MOVABLE_BUT_NOT_COPYABLE(optional) | 
					
						
							| 
									
										
										
										
											2018-01-03 20:55:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         boost::unordered::detail::value_base<T> value_; | 
					
						
							|  |  |  |         bool has_value_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         void destroy() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (has_value_) { | 
					
						
							|  |  |  |             boost::unordered::detail::func::destroy(value_.value_ptr()); | 
					
						
							|  |  |  |             has_value_ = false; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         void move(optional<T>& x) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           BOOST_ASSERT(!has_value_ && x.has_value_); | 
					
						
							|  |  |  |           new (value_.value_ptr()) T(boost::move(x.value_.value())); | 
					
						
							|  |  |  |           boost::unordered::detail::func::destroy(x.value_.value_ptr()); | 
					
						
							|  |  |  |           has_value_ = true; | 
					
						
							|  |  |  |           x.has_value_ = false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       public: | 
					
						
							|  |  |  |         optional() BOOST_NOEXCEPT : has_value_(false) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         optional(BOOST_RV_REF(optional<T>) x) : has_value_(false) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (x.has_value_) { | 
					
						
							|  |  |  |             move(x); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         explicit optional(T const& x) : has_value_(true) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new (value_.value_ptr()) T(x); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         optional& operator=(BOOST_RV_REF(optional<T>) x) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           destroy(); | 
					
						
							|  |  |  |           if (x.has_value_) { | 
					
						
							|  |  |  |             move(x); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           return *this; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ~optional() { destroy(); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         bool has_value() const { return has_value_; } | 
					
						
							|  |  |  |         T& operator*() { return value_.value(); } | 
					
						
							|  |  |  |         T const& operator*() const { return value_.value(); } | 
					
						
							|  |  |  |         T* operator->() { return value_.value_ptr(); } | 
					
						
							|  |  |  |         T const* operator->() const { return value_.value_ptr(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-18 10:19:20 -08:00
										 |  |  |         bool operator==(optional<T> const& x) const | 
					
						
							| 
									
										
										
										
											2018-01-03 20:55:44 +00:00
										 |  |  |         { | 
					
						
							|  |  |  |           return has_value_ ? x.has_value_ && value_.value() == x.value_.value() | 
					
						
							|  |  |  |                             : !x.has_value_; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-18 10:19:20 -08:00
										 |  |  |         bool operator!=(optional<T> const& x) const { return !((*this) == x); } | 
					
						
							| 
									
										
										
										
											2018-01-03 20:55:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         void swap(optional<T>& x) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (has_value_ != x.has_value_) { | 
					
						
							|  |  |  |             if (has_value_) { | 
					
						
							|  |  |  |               x.move(*this); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |               move(x); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } else if (has_value_) { | 
					
						
							|  |  |  |             boost::swap(value_.value(), x.value_.value()); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         friend void swap(optional<T>& x, optional<T>& y) { x.swap(y); } | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Allocator traits
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | namespace boost { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename Alloc> | 
					
						
							| 
									
										
										
										
											2021-12-07 08:35:56 -08:00
										 |  |  |       struct allocator_traits : boost::allocator_traits<Alloc> | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename Alloc, typename T> | 
					
						
							| 
									
										
										
										
											2021-12-07 08:35:56 -08:00
										 |  |  |       struct rebind_wrap : boost::allocator_rebind<Alloc, T> | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 20:14:26 +00:00
										 |  |  | ////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Functions used to construct nodes. Emulates variadic construction,
 | 
					
						
							|  |  |  | // piecewise construction etc.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | ////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | // construct_value
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Only use allocator_traits::construct, allocator_traits::destroy when full
 | 
					
						
							|  |  |  | // C++11 support is available.
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | #if BOOST_UNORDERED_CXX11_CONSTRUCTION
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | #elif !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  |       namespace func { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename T, typename... Args> | 
					
						
							|  |  |  |         inline void construct_value(T* address, BOOST_FWD_REF(Args)... args) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)address) T(boost::forward<Args>(args)...); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  |       namespace func { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename T> inline void construct_value(T* address) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)address) T(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename T, typename A0> | 
					
						
							|  |  |  |         inline void construct_value(T* address, BOOST_FWD_REF(A0) a0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)address) T(boost::forward<A0>(a0)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | ////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Construct from tuple
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | // Used to emulate piecewise construction.
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(z, n, namespace_)                 \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   template <typename Alloc, typename T,                                        \ | 
					
						
							|  |  |  |     BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)>                                  \ | 
					
						
							|  |  |  |   void construct_from_tuple(Alloc&, T* ptr,                                    \ | 
					
						
							|  |  |  |     namespace_::tuple<BOOST_PP_ENUM_PARAMS_Z(z, n, A)> const& x)               \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     new ((void*)ptr)                                                           \ | 
					
						
							|  |  |  |       T(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_GET_TUPLE_ARG, namespace_));      \ | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #define BOOST_UNORDERED_GET_TUPLE_ARG(z, n, namespace_) namespace_::get<n>(x)
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | // construct_from_tuple for boost::tuple
 | 
					
						
							| 
									
										
										
										
											2017-05-19 08:46:54 +01:00
										 |  |  | // The workaround for old Sun compilers comes later in the file.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if !BOOST_UNORDERED_SUN_WORKAROUNDS1
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  |       namespace func { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename T> | 
					
						
							|  |  |  |         void construct_from_tuple(Alloc&, T* ptr, boost::tuple<>) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)ptr) T(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 1, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 2, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 3, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 4, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 5, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 6, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 7, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 8, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 9, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 10, boost) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-19 08:46:54 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | // construct_from_tuple for std::tuple
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #if !BOOST_UNORDERED_CXX11_CONSTRUCTION && BOOST_UNORDERED_TUPLE_ARGS
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  |       namespace func { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename T> | 
					
						
							|  |  |  |         void construct_from_tuple(Alloc&, T* ptr, std::tuple<>) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)ptr) T(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 1, std) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 2, std) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 3, std) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 4, std) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 5, std) | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if BOOST_UNORDERED_TUPLE_ARGS >= 6
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_PP_REPEAT_FROM_TO(6, BOOST_PP_INC(BOOST_UNORDERED_TUPLE_ARGS), | 
					
						
							|  |  |  |           BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE, std) | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_GET_TUPLE_ARG
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-19 08:46:54 +01:00
										 |  |  | // construct_from_tuple for boost::tuple on old versions of sunpro.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Old versions of Sun C++ had problems with template overloads of
 | 
					
						
							|  |  |  | // boost::tuple, so to fix it I added a distinct type for each length to
 | 
					
						
							|  |  |  | // the overloads. That means there's no possible ambiguity between the
 | 
					
						
							|  |  |  | // different overloads, so that the compiler doesn't get confused
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if BOOST_UNORDERED_SUN_WORKAROUNDS1
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(z, n, namespace_)                 \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   template <typename Alloc, typename T,                                        \ | 
					
						
							|  |  |  |     BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)>                                  \ | 
					
						
							|  |  |  |   void construct_from_tuple_impl(boost::unordered::detail::func::length<n>,    \ | 
					
						
							|  |  |  |     Alloc&, T* ptr,                                                            \ | 
					
						
							|  |  |  |     namespace_::tuple<BOOST_PP_ENUM_PARAMS_Z(z, n, A)> const& x)               \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     new ((void*)ptr)                                                           \ | 
					
						
							|  |  |  |       T(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_GET_TUPLE_ARG, namespace_));      \ | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #define BOOST_UNORDERED_GET_TUPLE_ARG(z, n, namespace_) namespace_::get<n>(x)
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  |       namespace func { | 
					
						
							|  |  |  |         template <int N> struct length | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename T> | 
					
						
							|  |  |  |         void construct_from_tuple_impl( | 
					
						
							|  |  |  |           boost::unordered::detail::func::length<0>, Alloc&, T* ptr, | 
					
						
							|  |  |  |           boost::tuple<>) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)ptr) T(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 1, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 2, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 3, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 4, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 5, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 6, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 7, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 8, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 9, boost) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 10, boost) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <typename Alloc, typename T, typename Tuple> | 
					
						
							|  |  |  |         void construct_from_tuple(Alloc& alloc, T* ptr, Tuple const& x) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           construct_from_tuple_impl(boost::unordered::detail::func::length< | 
					
						
							|  |  |  |                                       boost::tuples::length<Tuple>::value>(), | 
					
						
							|  |  |  |             alloc, ptr, x); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 18:27:49 +01:00
										 |  |  | #undef BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_GET_TUPLE_ARG
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | namespace boost { | 
					
						
							|  |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  |       namespace func { | 
					
						
							|  |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Trait to check for piecewise construction.
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename A0> struct use_piecewise | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           static choice1::type test( | 
					
						
							|  |  |  |             choice1, boost::unordered::piecewise_construct_t); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           static choice2::type test(choice2, ...); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           enum | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             value = sizeof(choice1::type) == | 
					
						
							|  |  |  |                     sizeof(test(choose(), boost::unordered::detail::make<A0>())) | 
					
						
							|  |  |  |           }; | 
					
						
							|  |  |  |         }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | #if BOOST_UNORDERED_CXX11_CONSTRUCTION
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Construct from variadic parameters
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename T, typename... Args> | 
					
						
							|  |  |  |         inline void construct_from_args( | 
					
						
							|  |  |  |           Alloc& alloc, T* address, BOOST_FWD_REF(Args)... args) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           boost::allocator_construct( | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |             alloc, address, boost::forward<Args>(args)...); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // For backwards compatibility, implement a special case for
 | 
					
						
							|  |  |  |         // piecewise_construct with boost::tuple
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <typename A0> struct detect_boost_tuple | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           template <typename T0, typename T1, typename T2, typename T3, | 
					
						
							|  |  |  |             typename T4, typename T5, typename T6, typename T7, typename T8, | 
					
						
							|  |  |  |             typename T9> | 
					
						
							|  |  |  |           static choice1::type test(choice1, | 
					
						
							|  |  |  |             boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           static choice2::type test(choice2, ...); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           enum | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             value = sizeof(choice1::type) == | 
					
						
							|  |  |  |                     sizeof(test(choose(), boost::unordered::detail::make<A0>())) | 
					
						
							|  |  |  |           }; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // Special case for piecewise_construct
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class... Args, std::size_t... Is, class... TupleArgs> | 
					
						
							|  |  |  |         std::tuple<typename std::add_lvalue_reference<Args>::type...> | 
					
						
							|  |  |  |         to_std_tuple_impl(boost::mp11::mp_list<Args...>, | 
					
						
							|  |  |  |           boost::tuple<TupleArgs...>& tuple, boost::mp11::index_sequence<Is...>) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           (void) tuple; | 
					
						
							|  |  |  |           return std::tuple<typename std::add_lvalue_reference<Args>::type...>( | 
					
						
							|  |  |  |             boost::get<Is>(tuple)...); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <class... Args> | 
					
						
							|  |  |  |         boost::mp11::index_sequence_for<Args...> make_index_seq( | 
					
						
							|  |  |  |           boost::mp11::mp_list<Args...>) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return boost::mp11::index_sequence_for<Args...>{}; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <class T> | 
					
						
							|  |  |  |         using add_lvalue_reference_t = | 
					
						
							|  |  |  |           typename std::add_lvalue_reference<T>::type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <class... Args> | 
					
						
							|  |  |  |         boost::mp11::mp_transform<add_lvalue_reference_t, | 
					
						
							|  |  |  |           boost::mp11::mp_remove<std::tuple<Args...>, | 
					
						
							|  |  |  |             boost::tuples::null_type> > | 
					
						
							|  |  |  |         to_std_tuple(boost::tuple<Args...>& tuple) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           using list = boost::mp11::mp_remove<boost::mp11::mp_list<Args...>, | 
					
						
							|  |  |  |             boost::tuples::null_type>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           return to_std_tuple_impl(list{}, tuple, make_index_seq(list{})); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename A, typename B, typename A0, | 
					
						
							|  |  |  |           typename A1, typename A2> | 
					
						
							|  |  |  |         inline typename boost::enable_if_c<use_piecewise<A0>::value && | 
					
						
							|  |  |  |                                              detect_boost_tuple<A1>::value && | 
					
						
							|  |  |  |                                              detect_boost_tuple<A2>::value, | 
					
						
							|  |  |  |           void>::type | 
					
						
							|  |  |  |         construct_from_args(Alloc& alloc, std::pair<A, B>* address, | 
					
						
							|  |  |  |           BOOST_FWD_REF(A0), BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           boost::allocator_construct(alloc, address, std::piecewise_construct, | 
					
						
							|  |  |  |             to_std_tuple(a1), to_std_tuple(a2)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #elif !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Construct from variadic parameters
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename T, typename... Args> | 
					
						
							|  |  |  |         inline void construct_from_args( | 
					
						
							|  |  |  |           Alloc&, T* address, BOOST_FWD_REF(Args)... args) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)address) T(boost::forward<Args>(args)...); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Special case for piecewise_construct
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <typename Alloc, typename A, typename B, typename A0, | 
					
						
							|  |  |  |           typename A1, typename A2> | 
					
						
							|  |  |  |         inline typename enable_if<use_piecewise<A0>, void>::type | 
					
						
							|  |  |  |         construct_from_args(Alloc& alloc, std::pair<A, B>* address, | 
					
						
							|  |  |  |           BOOST_FWD_REF(A0), BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           boost::unordered::detail::func::construct_from_tuple( | 
					
						
							|  |  |  |             alloc, boost::addressof(address->first), boost::forward<A1>(a1)); | 
					
						
							|  |  |  |           BOOST_TRY | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::construct_from_tuple( | 
					
						
							|  |  |  |               alloc, boost::addressof(address->second), boost::forward<A2>(a2)); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH(...) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::destroy( | 
					
						
							|  |  |  |               boost::addressof(address->first)); | 
					
						
							|  |  |  |             BOOST_RETHROW | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH_END | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else // BOOST_NO_CXX11_VARIADIC_TEMPLATES
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Construct from emplace_args
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Explicitly write out first three overloads for the sake of sane
 | 
					
						
							|  |  |  |         // error messages.
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename T, typename A0> | 
					
						
							|  |  |  |         inline void construct_from_args( | 
					
						
							|  |  |  |           Alloc&, T* address, emplace_args1<A0> const& args) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)address) T(boost::forward<A0>(args.a0)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename T, typename A0, typename A1> | 
					
						
							|  |  |  |         inline void construct_from_args( | 
					
						
							|  |  |  |           Alloc&, T* address, emplace_args2<A0, A1> const& args) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)address) | 
					
						
							|  |  |  |             T(boost::forward<A0>(args.a0), boost::forward<A1>(args.a1)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename T, typename A0, typename A1, | 
					
						
							|  |  |  |           typename A2> | 
					
						
							|  |  |  |         inline void construct_from_args( | 
					
						
							|  |  |  |           Alloc&, T* address, emplace_args3<A0, A1, A2> const& args) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           new ((void*)address) T(boost::forward<A0>(args.a0), | 
					
						
							|  |  |  |             boost::forward<A1>(args.a1), boost::forward<A2>(args.a2)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | // Use a macro for the rest.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_CONSTRUCT_IMPL(z, num_params, _)                       \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   template <typename Alloc, typename T,                                        \ | 
					
						
							|  |  |  |     BOOST_PP_ENUM_PARAMS_Z(z, num_params, typename A)>                         \ | 
					
						
							|  |  |  |   inline void construct_from_args(Alloc&, T* address,                          \ | 
					
						
							|  |  |  |     boost::unordered::detail::BOOST_PP_CAT(emplace_args, num_params) <         \ | 
					
						
							|  |  |  |       BOOST_PP_ENUM_PARAMS_Z(z, num_params, A) > const& args)                  \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     new ((void*)address)                                                       \ | 
					
						
							|  |  |  |       T(BOOST_PP_ENUM_##z(num_params, BOOST_UNORDERED_CALL_FORWARD, args.a));  \ | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_IMPL(1, 4, _) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_IMPL(1, 5, _) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_IMPL(1, 6, _) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_IMPL(1, 7, _) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_IMPL(1, 8, _) | 
					
						
							|  |  |  |         BOOST_UNORDERED_CONSTRUCT_IMPL(1, 9, _) | 
					
						
							|  |  |  |         BOOST_PP_REPEAT_FROM_TO(10, BOOST_PP_INC(BOOST_UNORDERED_EMPLACE_LIMIT), | 
					
						
							|  |  |  |           BOOST_UNORDERED_CONSTRUCT_IMPL, _) | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_CONSTRUCT_IMPL
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Construct with piecewise_construct
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <typename Alloc, typename A, typename B, typename A0, | 
					
						
							|  |  |  |           typename A1, typename A2> | 
					
						
							| 
									
										
										
										
											2021-11-18 12:54:17 -08:00
										 |  |  |         inline typename enable_if<use_piecewise<A0>, void>::type | 
					
						
							|  |  |  |         construct_from_args(Alloc& alloc, std::pair<A, B>* address, | 
					
						
							|  |  |  |           boost::unordered::detail::emplace_args3<A0, A1, A2> const& args) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           boost::unordered::detail::func::construct_from_tuple( | 
					
						
							|  |  |  |             alloc, boost::addressof(address->first), args.a1); | 
					
						
							|  |  |  |           BOOST_TRY | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::construct_from_tuple( | 
					
						
							|  |  |  |               alloc, boost::addressof(address->second), args.a2); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH(...) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::destroy( | 
					
						
							|  |  |  |               boost::addressof(address->first)); | 
					
						
							|  |  |  |             BOOST_RETHROW | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH_END | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif // BOOST_NO_CXX11_VARIADIC_TEMPLATES
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | namespace boost { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       ///////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |       //
 | 
					
						
							|  |  |  |       // Node construction
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename NodeAlloc> struct node_constructor | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef NodeAlloc node_allocator; | 
					
						
							|  |  |  |         typedef boost::unordered::detail::allocator_traits<NodeAlloc> | 
					
						
							|  |  |  |           node_allocator_traits; | 
					
						
							|  |  |  |         typedef typename node_allocator_traits::value_type node; | 
					
						
							|  |  |  |         typedef typename node_allocator_traits::pointer node_pointer; | 
					
						
							|  |  |  |         typedef typename node::value_type value_type; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         node_allocator& alloc_; | 
					
						
							|  |  |  |         node_pointer node_; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         node_constructor(node_allocator& n) : alloc_(n), node_() {} | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ~node_constructor(); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void create_node(); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // no throw
 | 
					
						
							|  |  |  |         node_pointer release() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           BOOST_ASSERT(node_); | 
					
						
							|  |  |  |           node_pointer p = node_; | 
					
						
							|  |  |  |           node_ = node_pointer(); | 
					
						
							|  |  |  |           return p; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       private: | 
					
						
							|  |  |  |         node_constructor(node_constructor const&); | 
					
						
							|  |  |  |         node_constructor& operator=(node_constructor const&); | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename Alloc> node_constructor<Alloc>::~node_constructor() | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         if (node_) { | 
					
						
							| 
									
										
										
										
											2018-01-26 20:25:09 +00:00
										 |  |  |           boost::unordered::detail::func::destroy(boost::to_address(node_)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           node_allocator_traits::deallocate(alloc_, node_, 1); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename Alloc> void node_constructor<Alloc>::create_node() | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         BOOST_ASSERT(!node_); | 
					
						
							|  |  |  |         node_ = node_allocator_traits::allocate(alloc_, 1); | 
					
						
							| 
									
										
										
										
											2018-01-27 09:38:19 +00:00
										 |  |  |         new ((void*)boost::to_address(node_)) node(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename NodeAlloc> struct node_tmp | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         typedef typename boost::allocator_value_type<NodeAlloc>::type node; | 
					
						
							|  |  |  |         typedef typename boost::allocator_pointer<NodeAlloc>::type node_pointer; | 
					
						
							|  |  |  |         typedef typename node::value_type value_type; | 
					
						
							|  |  |  |         typedef typename boost::allocator_rebind<NodeAlloc, value_type>::type | 
					
						
							|  |  |  |           value_allocator; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         NodeAlloc& alloc_; | 
					
						
							|  |  |  |         node_pointer node_; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         explicit node_tmp(node_pointer n, NodeAlloc& a) : alloc_(a), node_(n) {} | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ~node_tmp(); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // no throw
 | 
					
						
							|  |  |  |         node_pointer release() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_pointer p = node_; | 
					
						
							|  |  |  |           node_ = node_pointer(); | 
					
						
							|  |  |  |           return p; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename Alloc> node_tmp<Alloc>::~node_tmp() | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         if (node_) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           value_allocator val_alloc(alloc_); | 
					
						
							|  |  |  |           boost::allocator_destroy(val_alloc, node_->value_ptr()); | 
					
						
							|  |  |  |           boost::allocator_deallocate(alloc_, node_, 1); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace boost { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   namespace unordered { | 
					
						
							|  |  |  |     namespace detail { | 
					
						
							|  |  |  |       namespace func { | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Some nicer construct_node functions, might try to
 | 
					
						
							|  |  |  |         // improve implementation later.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <typename Alloc, BOOST_UNORDERED_EMPLACE_TEMPLATE> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         inline typename boost::allocator_pointer<Alloc>::type | 
					
						
							|  |  |  |         construct_node_from_args(Alloc& alloc, BOOST_UNORDERED_EMPLACE_ARGS) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           typedef typename boost::allocator_value_type<Alloc>::type node; | 
					
						
							|  |  |  |           typedef typename node::value_type value_type; | 
					
						
							|  |  |  |           typedef typename boost::allocator_rebind<Alloc, value_type>::type | 
					
						
							|  |  |  |             value_allocator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           value_allocator val_alloc(alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           node_constructor<Alloc> a(alloc); | 
					
						
							|  |  |  |           a.create_node(); | 
					
						
							|  |  |  |           construct_from_args( | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             val_alloc, a.node_->value_ptr(), BOOST_UNORDERED_EMPLACE_FORWARD); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return a.release(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <typename Alloc, typename U> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         inline typename boost::allocator_pointer<Alloc>::type construct_node( | 
					
						
							|  |  |  |           Alloc& alloc, BOOST_FWD_REF(U) x) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           node_constructor<Alloc> a(alloc); | 
					
						
							|  |  |  |           a.create_node(); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           typedef typename boost::allocator_value_type<Alloc>::type node; | 
					
						
							|  |  |  |           typedef typename node::value_type value_type; | 
					
						
							|  |  |  |           typedef typename boost::allocator_rebind<Alloc, value_type>::type | 
					
						
							|  |  |  |             value_allocator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           value_allocator val_alloc(alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           boost::allocator_construct( | 
					
						
							|  |  |  |             val_alloc, a.node_->value_ptr(), boost::forward<U>(x)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return a.release(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | #if BOOST_UNORDERED_CXX11_CONSTRUCTION
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename Key> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         inline typename boost::allocator_pointer<Alloc>::type | 
					
						
							|  |  |  |         construct_node_pair(Alloc& alloc, BOOST_FWD_REF(Key) k) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           node_constructor<Alloc> a(alloc); | 
					
						
							|  |  |  |           a.create_node(); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           typedef typename boost::allocator_value_type<Alloc>::type node; | 
					
						
							|  |  |  |           typedef typename node::value_type value_type; | 
					
						
							|  |  |  |           typedef typename boost::allocator_rebind<Alloc, value_type>::type | 
					
						
							|  |  |  |             value_allocator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           value_allocator val_alloc(alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           boost::allocator_construct( | 
					
						
							|  |  |  |             val_alloc, a.node_->value_ptr(), std::piecewise_construct, | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |             std::forward_as_tuple(boost::forward<Key>(k)), | 
					
						
							|  |  |  |             std::forward_as_tuple()); | 
					
						
							|  |  |  |           return a.release(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename Key, typename Mapped> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         inline typename boost::allocator_pointer<Alloc>::type | 
					
						
							|  |  |  |         construct_node_pair( | 
					
						
							|  |  |  |           Alloc& alloc, BOOST_FWD_REF(Key) k, BOOST_FWD_REF(Mapped) m) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           node_constructor<Alloc> a(alloc); | 
					
						
							|  |  |  |           a.create_node(); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           typedef typename boost::allocator_value_type<Alloc>::type node; | 
					
						
							|  |  |  |           typedef typename node::value_type value_type; | 
					
						
							|  |  |  |           typedef typename boost::allocator_rebind<Alloc, value_type>::type | 
					
						
							|  |  |  |             value_allocator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           value_allocator val_alloc(alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           boost::allocator_construct(val_alloc, a.node_->value_ptr(), | 
					
						
							|  |  |  |             std::piecewise_construct, | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |             std::forward_as_tuple(boost::forward<Key>(k)), | 
					
						
							|  |  |  |             std::forward_as_tuple(boost::forward<Mapped>(m))); | 
					
						
							|  |  |  |           return a.release(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename Key, typename... Args> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         inline typename boost::allocator_pointer<Alloc>::type | 
					
						
							|  |  |  |         construct_node_pair_from_args( | 
					
						
							|  |  |  |           Alloc& alloc, BOOST_FWD_REF(Key) k, BOOST_FWD_REF(Args)... args) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           node_constructor<Alloc> a(alloc); | 
					
						
							|  |  |  |           a.create_node(); | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:52 +01:00
										 |  |  | #if !(BOOST_COMP_CLANG && BOOST_COMP_CLANG < BOOST_VERSION_NUMBER(3, 8, 0) &&  \
 | 
					
						
							|  |  |  |       defined(BOOST_LIBSTDCXX11)) | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           typedef typename boost::allocator_value_type<Alloc>::type node; | 
					
						
							|  |  |  |           typedef typename node::value_type value_type; | 
					
						
							|  |  |  |           typedef typename boost::allocator_rebind<Alloc, value_type>::type | 
					
						
							|  |  |  |             value_allocator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           value_allocator val_alloc(alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           boost::allocator_construct(val_alloc, a.node_->value_ptr(), | 
					
						
							|  |  |  |             std::piecewise_construct, | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |             std::forward_as_tuple(boost::forward<Key>(k)), | 
					
						
							|  |  |  |             std::forward_as_tuple(boost::forward<Args>(args)...)); | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:52 +01:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           // It doesn't seem to be possible to construct a tuple with 3 variadic
 | 
					
						
							|  |  |  |           // rvalue reference members when using older versions of clang with
 | 
					
						
							|  |  |  |           // libstdc++, so just use std::make_tuple instead of
 | 
					
						
							|  |  |  |           // std::forward_as_tuple.
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           boost::allocator_construct(val_alloc, a.node_->value_ptr(), | 
					
						
							|  |  |  |             std::piecewise_construct, | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |             std::forward_as_tuple(boost::forward<Key>(k)), | 
					
						
							|  |  |  |             std::make_tuple(boost::forward<Args>(args)...)); | 
					
						
							| 
									
										
										
										
											2017-05-03 04:21:52 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return a.release(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename Key> | 
					
						
							|  |  |  |         inline | 
					
						
							|  |  |  |           typename boost::unordered::detail::allocator_traits<Alloc>::pointer | 
					
						
							|  |  |  |           construct_node_pair(Alloc& alloc, BOOST_FWD_REF(Key) k) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_constructor<Alloc> a(alloc); | 
					
						
							|  |  |  |           a.create_node(); | 
					
						
							|  |  |  |           boost::unordered::detail::func::construct_value( | 
					
						
							|  |  |  |             boost::addressof(a.node_->value_ptr()->first), | 
					
						
							|  |  |  |             boost::forward<Key>(k)); | 
					
						
							|  |  |  |           BOOST_TRY | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::construct_value( | 
					
						
							|  |  |  |               boost::addressof(a.node_->value_ptr()->second)); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH(...) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::destroy( | 
					
						
							|  |  |  |               boost::addressof(a.node_->value_ptr()->first)); | 
					
						
							|  |  |  |             BOOST_RETHROW | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH_END | 
					
						
							|  |  |  |           return a.release(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename Key, typename Mapped> | 
					
						
							|  |  |  |         inline | 
					
						
							|  |  |  |           typename boost::unordered::detail::allocator_traits<Alloc>::pointer | 
					
						
							|  |  |  |           construct_node_pair( | 
					
						
							|  |  |  |             Alloc& alloc, BOOST_FWD_REF(Key) k, BOOST_FWD_REF(Mapped) m) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_constructor<Alloc> a(alloc); | 
					
						
							|  |  |  |           a.create_node(); | 
					
						
							|  |  |  |           boost::unordered::detail::func::construct_value( | 
					
						
							|  |  |  |             boost::addressof(a.node_->value_ptr()->first), | 
					
						
							|  |  |  |             boost::forward<Key>(k)); | 
					
						
							|  |  |  |           BOOST_TRY | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::construct_value( | 
					
						
							|  |  |  |               boost::addressof(a.node_->value_ptr()->second), | 
					
						
							|  |  |  |               boost::forward<Mapped>(m)); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH(...) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::destroy( | 
					
						
							|  |  |  |               boost::addressof(a.node_->value_ptr()->first)); | 
					
						
							|  |  |  |             BOOST_RETHROW | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH_END | 
					
						
							|  |  |  |           return a.release(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Alloc, typename Key, | 
					
						
							|  |  |  |           BOOST_UNORDERED_EMPLACE_TEMPLATE> | 
					
						
							|  |  |  |         inline | 
					
						
							|  |  |  |           typename boost::unordered::detail::allocator_traits<Alloc>::pointer | 
					
						
							|  |  |  |           construct_node_pair_from_args( | 
					
						
							|  |  |  |             Alloc& alloc, BOOST_FWD_REF(Key) k, BOOST_UNORDERED_EMPLACE_ARGS) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_constructor<Alloc> a(alloc); | 
					
						
							|  |  |  |           a.create_node(); | 
					
						
							|  |  |  |           boost::unordered::detail::func::construct_value( | 
					
						
							|  |  |  |             boost::addressof(a.node_->value_ptr()->first), | 
					
						
							|  |  |  |             boost::forward<Key>(k)); | 
					
						
							|  |  |  |           BOOST_TRY | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::construct_from_args(alloc, | 
					
						
							|  |  |  |               boost::addressof(a.node_->value_ptr()->second), | 
					
						
							|  |  |  |               BOOST_UNORDERED_EMPLACE_FORWARD); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH(...) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             boost::unordered::detail::func::destroy( | 
					
						
							|  |  |  |               boost::addressof(a.node_->value_ptr()->first)); | 
					
						
							|  |  |  |             BOOST_RETHROW | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH_END | 
					
						
							|  |  |  |           return a.release(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 10:14:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #pragma warning(pop)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | namespace boost { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   namespace unordered { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |     namespace detail { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       // Functions
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       // This double buffers the storage for the hash function and key equality
 | 
					
						
							|  |  |  |       // predicate in order to have exception safe copy/swap. To do so,
 | 
					
						
							|  |  |  |       // use 'construct_spare' to construct in the spare space, and then when
 | 
					
						
							|  |  |  |       // ready to use 'switch_functions' to switch to the new functions.
 | 
					
						
							|  |  |  |       // If an exception is thrown between these two calls, use
 | 
					
						
							|  |  |  |       // 'cleanup_spare_functions' to destroy the unused constructed functions.
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       template <class H, class P> class functions | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							|  |  |  |       public: | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         static const bool nothrow_move_assignable = | 
					
						
							|  |  |  |           boost::is_nothrow_move_assignable<H>::value && | 
					
						
							|  |  |  |           boost::is_nothrow_move_assignable<P>::value; | 
					
						
							|  |  |  |         static const bool nothrow_move_constructible = | 
					
						
							|  |  |  |           boost::is_nothrow_move_constructible<H>::value && | 
					
						
							|  |  |  |           boost::is_nothrow_move_constructible<P>::value; | 
					
						
							|  |  |  |         static const bool nothrow_swappable = | 
					
						
							|  |  |  |           boost::is_nothrow_swappable<H>::value && | 
					
						
							|  |  |  |           boost::is_nothrow_swappable<P>::value; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       private: | 
					
						
							|  |  |  |         functions& operator=(functions const&); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         typedef compressed<H, P> function_pair; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         typedef typename boost::aligned_storage<sizeof(function_pair), | 
					
						
							|  |  |  |           boost::alignment_of<function_pair>::value>::type aligned_function; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         unsigned char current_; // 0/1 - Currently active functions
 | 
					
						
							|  |  |  |                                 // +2 - Both constructed
 | 
					
						
							|  |  |  |         aligned_function funcs_[2]; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       public: | 
					
						
							|  |  |  |         functions(H const& hf, P const& eq) : current_(0) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           construct_functions(current_, hf, eq); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         functions(functions const& bf) : current_(0) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           construct_functions(current_, bf.current_functions()); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         functions(functions& bf, boost::unordered::detail::move_tag) | 
					
						
							|  |  |  |             : current_(0) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           construct_functions(current_, bf.current_functions(), | 
					
						
							|  |  |  |             boost::unordered::detail::integral_constant<bool, | 
					
						
							|  |  |  |               nothrow_move_constructible>()); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         ~functions() | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(!(current_ & 2)); | 
					
						
							|  |  |  |           destroy_functions(current_); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         H const& hash_function() const { return current_functions().first(); } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         P const& key_eq() const { return current_functions().second(); } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         function_pair const& current_functions() const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return *static_cast<function_pair const*>( | 
					
						
							|  |  |  |             static_cast<void const*>(funcs_[current_ & 1].address())); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         function_pair& current_functions() | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return *static_cast<function_pair*>( | 
					
						
							|  |  |  |             static_cast<void*>(funcs_[current_ & 1].address())); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void construct_spare_functions(function_pair const& f) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(!(current_ & 2)); | 
					
						
							|  |  |  |           construct_functions(current_ ^ 1, f); | 
					
						
							|  |  |  |           current_ |= 2; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void cleanup_spare_functions() | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (current_ & 2) { | 
					
						
							|  |  |  |             current_ = static_cast<unsigned char>(current_ & 1); | 
					
						
							|  |  |  |             destroy_functions(current_ ^ 1); | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void switch_functions() | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(current_ & 2); | 
					
						
							|  |  |  |           destroy_functions(static_cast<unsigned char>(current_ & 1)); | 
					
						
							|  |  |  |           current_ ^= 3; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       private: | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void construct_functions(unsigned char which, H const& hf, P const& eq) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(!(which & 2)); | 
					
						
							|  |  |  |           new ((void*)&funcs_[which]) function_pair(hf, eq); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void construct_functions(unsigned char which, function_pair const& f, | 
					
						
							|  |  |  |           boost::unordered::detail::false_type = | 
					
						
							|  |  |  |             boost::unordered::detail::false_type()) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(!(which & 2)); | 
					
						
							|  |  |  |           new ((void*)&funcs_[which]) function_pair(f); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void construct_functions(unsigned char which, function_pair& f, | 
					
						
							|  |  |  |           boost::unordered::detail::true_type) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(!(which & 2)); | 
					
						
							|  |  |  |           new ((void*)&funcs_[which]) | 
					
						
							|  |  |  |             function_pair(f, boost::unordered::detail::move_tag()); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void destroy_functions(unsigned char which) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(!(which & 2)); | 
					
						
							|  |  |  |           boost::unordered::detail::func::destroy( | 
					
						
							|  |  |  |             (function_pair*)(&funcs_[which])); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | ////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // rvalue parameters when type can't be a BOOST_RV_REF(T) parameter
 | 
					
						
							|  |  |  | // e.g. for int
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
 | 
					
						
							|  |  |  | #define BOOST_UNORDERED_RV_REF(T) BOOST_RV_REF(T)
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |       struct please_ignore_this_overload | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef please_ignore_this_overload type; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       template <typename T> struct rv_ref_impl | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         typedef BOOST_RV_REF(T) type; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       template <typename T> | 
					
						
							|  |  |  |       struct rv_ref | 
					
						
							|  |  |  |         : boost::detail::if_true<boost::is_class<T>::value>:: | 
					
						
							|  |  |  |             BOOST_NESTED_TEMPLATE then<boost::unordered::detail::rv_ref_impl<T>, | 
					
						
							|  |  |  |               please_ignore_this_overload>::type | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | #define BOOST_UNORDERED_RV_REF(T)                                              \
 | 
					
						
							|  |  |  |   typename boost::unordered::detail::rv_ref<T>::type | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | #if defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #pragma warning(push)
 | 
					
						
							|  |  |  | #pragma warning(disable : 4127) // conditional expression is constant
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       // convert double to std::size_t
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       inline std::size_t double_to_size(double f) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         return f >= static_cast<double>( | 
					
						
							|  |  |  |                       (std::numeric_limits<std::size_t>::max)()) | 
					
						
							|  |  |  |                  ? (std::numeric_limits<std::size_t>::max)() | 
					
						
							|  |  |  |                  : static_cast<std::size_t>(f); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |       // iterator definitions
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       namespace iterator_detail { | 
					
						
							|  |  |  |         template <class Node, class Bucket> class c_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <class Node, class Bucket> | 
					
						
							|  |  |  |         class iterator | 
					
						
							|  |  |  |             : public boost::iterator_facade<iterator<Node, Bucket>, | 
					
						
							|  |  |  |                 typename Node::value_type, boost::forward_traversal_tag> | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         public: | 
					
						
							|  |  |  |           typedef typename Node::value_type value_type; | 
					
						
							|  |  |  |           typedef value_type element_type; | 
					
						
							|  |  |  |           typedef value_type* pointer; | 
					
						
							|  |  |  |           typedef value_type& reference; | 
					
						
							|  |  |  |           typedef std::ptrdiff_t difference_type; | 
					
						
							|  |  |  |           typedef std::forward_iterator_tag iterator_category; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           iterator() : p(), itb(){}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private: | 
					
						
							|  |  |  |           typedef typename Node::node_pointer node_pointer; | 
					
						
							|  |  |  |           typedef grouped_bucket_iterator<Bucket> bucket_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           node_pointer p; | 
					
						
							|  |  |  |           bucket_iterator itb; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           template <class Types> friend struct boost::unordered::detail::table; | 
					
						
							|  |  |  |           template <class N, class B> friend class c_iterator; | 
					
						
							|  |  |  |           friend class boost::iterator_core_access; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           iterator(node_pointer p_, bucket_iterator itb_) : p(p_), itb(itb_) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           value_type& dereference() const BOOST_NOEXCEPT { return p->value(); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           bool equal(const iterator& x) const BOOST_NOEXCEPT | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             return (p == x.p); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           void increment() BOOST_NOEXCEPT | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             p = p->next; | 
					
						
							|  |  |  |             if (!p) { | 
					
						
							|  |  |  |               p = (++itb)->next; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <class Node, class Bucket> | 
					
						
							|  |  |  |         class c_iterator | 
					
						
							|  |  |  |             : public boost::iterator_facade<c_iterator<Node, Bucket>, | 
					
						
							|  |  |  |                 typename Node::value_type const, boost::forward_traversal_tag> | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         public: | 
					
						
							|  |  |  |           typedef typename Node::value_type value_type; | 
					
						
							|  |  |  |           typedef value_type const element_type; | 
					
						
							|  |  |  |           typedef value_type const* pointer; | 
					
						
							|  |  |  |           typedef value_type const& reference; | 
					
						
							|  |  |  |           typedef std::ptrdiff_t difference_type; | 
					
						
							|  |  |  |           typedef std::forward_iterator_tag iterator_category; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           c_iterator() : p(), itb(){}; | 
					
						
							|  |  |  |           c_iterator(iterator<Node, Bucket> it) : p(it.p), itb(it.itb){}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private: | 
					
						
							|  |  |  |           typedef typename Node::node_pointer node_pointer; | 
					
						
							|  |  |  |           typedef grouped_bucket_iterator<Bucket> bucket_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           node_pointer p; | 
					
						
							|  |  |  |           bucket_iterator itb; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           template <class Types> friend struct boost::unordered::detail::table; | 
					
						
							|  |  |  |           friend class boost::iterator_core_access; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           c_iterator(node_pointer p_, bucket_iterator itb_) : p(p_), itb(itb_) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           value_type const& dereference() const BOOST_NOEXCEPT | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             return p->value(); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           bool equal(const c_iterator& x) const BOOST_NOEXCEPT | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             return (p == x.p); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           void increment() BOOST_NOEXCEPT | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             p = p->next; | 
					
						
							|  |  |  |             if (!p) { | 
					
						
							|  |  |  |               p = (++itb)->next; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |       } // namespace iterator_detail
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |       // table structure used by the containers
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename Types> | 
					
						
							|  |  |  |       struct table : boost::unordered::detail::functions<typename Types::hasher, | 
					
						
							|  |  |  |                        typename Types::key_equal> | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |       private: | 
					
						
							|  |  |  |         table(table const&); | 
					
						
							|  |  |  |         table& operator=(table const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       public: | 
					
						
							|  |  |  |         typedef typename Types::hasher hasher; | 
					
						
							|  |  |  |         typedef typename Types::key_equal key_equal; | 
					
						
							|  |  |  |         typedef typename Types::const_key_type const_key_type; | 
					
						
							|  |  |  |         typedef typename Types::extractor extractor; | 
					
						
							|  |  |  |         typedef typename Types::value_type value_type; | 
					
						
							|  |  |  |         typedef typename Types::table table_impl; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef boost::unordered::detail::functions<typename Types::hasher, | 
					
						
							|  |  |  |           typename Types::key_equal> | 
					
						
							|  |  |  |           functions; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef typename Types::value_allocator value_allocator; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         typedef typename boost::allocator_void_pointer<value_allocator>::type void_pointer; | 
					
						
							|  |  |  |         typedef node<value_type, void_pointer> node_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef boost::unordered::detail::grouped_bucket_array< | 
					
						
							|  |  |  |           bucket<node_type, void_pointer>, value_allocator, prime_fmod_size<> > | 
					
						
							|  |  |  |           bucket_array_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef typename bucket_array_type::node_allocator_type | 
					
						
							|  |  |  |           node_allocator_type; | 
					
						
							|  |  |  |         typedef typename boost::allocator_pointer<node_allocator_type>::type node_pointer; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef boost::unordered::detail::node_constructor<node_allocator_type> | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           node_constructor; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         typedef boost::unordered::detail::node_tmp<node_allocator_type> node_tmp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef typename bucket_array_type::bucket_type bucket_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef typename bucket_array_type::iterator bucket_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef typename bucket_array_type::local_iterator l_iterator; | 
					
						
							|  |  |  |         typedef typename bucket_array_type::const_local_iterator cl_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef std::size_t size_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef iterator_detail::iterator<node_type, bucket_type> iterator; | 
					
						
							|  |  |  |         typedef iterator_detail::c_iterator<node_type, bucket_type> c_iterator; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         typedef std::pair<iterator, bool> emplace_return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Members
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         std::size_t size_; | 
					
						
							|  |  |  |         float mlf_; | 
					
						
							|  |  |  |         std::size_t max_load_; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         bucket_array_type buckets_; | 
					
						
							| 
									
										
										
										
											2022-01-19 02:33:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       public: | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Data access
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         size_type bucket_count() const { return buckets_.bucket_count(); } | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class Key> | 
					
						
							|  |  |  |         iterator next_group(Key const& k, c_iterator n) const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           c_iterator last = this->end(); | 
					
						
							|  |  |  |           while (n != last && this->key_eq()(k, extractor::extract(*n))) { | 
					
						
							|  |  |  |             ++n; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           return iterator(n.p, n.itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class Key> std::size_t group_count(Key const& k) const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (size_ == 0) { | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           std::size_t c = 0; | 
					
						
							|  |  |  |           std::size_t const key_hash = this->hash(k); | 
					
						
							|  |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bool found = false; | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           for (node_pointer pos = itb->next; pos; pos = pos->next) { | 
					
						
							|  |  |  |             if (this->key_eq()(k, this->get_key(pos))) { | 
					
						
							|  |  |  |               ++c; | 
					
						
							|  |  |  |               found = true; | 
					
						
							|  |  |  |             } else if (found) { | 
					
						
							|  |  |  |               break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           return c; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         node_allocator_type const& node_alloc() const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return buckets_.get_node_allocator(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         node_allocator_type& node_alloc() | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return buckets_.get_node_allocator(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         std::size_t max_bucket_count() const | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           typedef typename bucket_array_type::size_policy size_policy; | 
					
						
							|  |  |  |           return size_policy::size(size_policy::size_index( | 
					
						
							|  |  |  |             boost::allocator_max_size(this->node_alloc()))); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         iterator begin() const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (size_ == 0) { | 
					
						
							|  |  |  |             return end(); | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = buckets_.begin(); | 
					
						
							|  |  |  |           return iterator(itb->next, itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         iterator end() const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return iterator(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         l_iterator begin(std::size_t bucket_index) const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return buckets_.begin(bucket_index); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         std::size_t hash_to_bucket(std::size_t hash_value) const | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return buckets_.position(hash_value); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         std::size_t bucket_size(std::size_t index) const | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = buckets_.at(index); | 
					
						
							|  |  |  |           node_pointer n = itb->next; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           std::size_t count = 0; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           while (n) { | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |             ++count; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             n = n->next; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							|  |  |  |           return count; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Load methods
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void recalculate_max_load() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           using namespace std; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           // From 6.3.1/13:
 | 
					
						
							|  |  |  |           // Only resize when size >= mlf_ * count
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           max_load_ = boost::unordered::detail::double_to_size( | 
					
						
							|  |  |  |             floor(static_cast<double>(mlf_) * | 
					
						
							|  |  |  |                  static_cast<double>(buckets_.bucket_count()))); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void max_load_factor(float z) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           BOOST_ASSERT(z > 0); | 
					
						
							|  |  |  |           mlf_ = (std::max)(z, minimum_max_load_factor); | 
					
						
							|  |  |  |           recalculate_max_load(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Constructors
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         table(std::size_t num_buckets, hasher const& hf, key_equal const& eq, | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           node_allocator_type const& a) | 
					
						
							|  |  |  |             : functions(hf, eq), size_(0), mlf_(1.0f), max_load_(0), | 
					
						
							|  |  |  |               buckets_(num_buckets, a) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           recalculate_max_load(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         table(table const& x, node_allocator_type const& a) | 
					
						
							|  |  |  |             : functions(x), size_(0), mlf_(x.mlf_), max_load_(0), | 
					
						
							|  |  |  |               buckets_(x.size_, a) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           recalculate_max_load(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         table(table& x, boost::unordered::detail::move_tag m) | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             : functions(x, m), size_(x.size_), mlf_(x.mlf_), | 
					
						
							|  |  |  |               max_load_(x.max_load_), buckets_(boost::move(x.buckets_)) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           x.size_ = 0; | 
					
						
							|  |  |  |           x.max_load_ = 0; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         table(table& x, node_allocator_type const& a, | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           boost::unordered::detail::move_tag m) | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             : functions(x, m), size_(0), mlf_(x.mlf_), max_load_(0), | 
					
						
							|  |  |  |               buckets_(x.bucket_count(), a) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           recalculate_max_load(); | 
					
						
							| 
									
										
										
										
											2017-04-30 10:41:22 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Swap and Move
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void swap_allocators(table& other, false_type) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           boost::unordered::detail::func::ignore_unused_variable_warning(other); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           // According to 23.2.1.8, if propagate_on_container_swap is
 | 
					
						
							|  |  |  |           // false the behaviour is undefined unless the allocators
 | 
					
						
							|  |  |  |           // are equal.
 | 
					
						
							|  |  |  |           BOOST_ASSERT(node_alloc() == other.node_alloc()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-05 17:48:13 +00:00
										 |  |  |         // Not nothrow swappable
 | 
					
						
							|  |  |  |         void swap(table& x, false_type) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-01-08 10:58:09 +00:00
										 |  |  |           if (this == &x) { | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |           this->construct_spare_functions(x.current_functions()); | 
					
						
							| 
									
										
										
										
											2018-01-08 10:58:09 +00:00
										 |  |  |           BOOST_TRY { x.construct_spare_functions(this->current_functions()); } | 
					
						
							|  |  |  |           BOOST_CATCH(...) | 
					
						
							|  |  |  |           { | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |             this->cleanup_spare_functions(); | 
					
						
							|  |  |  |             BOOST_RETHROW | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH_END | 
					
						
							|  |  |  |           this->switch_functions(); | 
					
						
							|  |  |  |           x.switch_functions(); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           buckets_.swap(x.buckets_); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           boost::swap(size_, x.size_); | 
					
						
							|  |  |  |           std::swap(mlf_, x.mlf_); | 
					
						
							|  |  |  |           std::swap(max_load_, x.max_load_); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-05 17:48:13 +00:00
										 |  |  |         // Nothrow swappable
 | 
					
						
							|  |  |  |         void swap(table& x, true_type) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           buckets_.swap(x.buckets_); | 
					
						
							| 
									
										
										
										
											2018-01-05 17:48:13 +00:00
										 |  |  |           boost::swap(size_, x.size_); | 
					
						
							|  |  |  |           std::swap(mlf_, x.mlf_); | 
					
						
							|  |  |  |           std::swap(max_load_, x.max_load_); | 
					
						
							|  |  |  |           this->current_functions().swap(x.current_functions()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // Only swaps the allocators if propagate_on_container_swap.
 | 
					
						
							|  |  |  |         // If not propagate_on_container_swap and allocators aren't
 | 
					
						
							|  |  |  |         // equal, behaviour is undefined.
 | 
					
						
							|  |  |  |         void swap(table& x) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(boost::allocator_propagate_on_container_swap< | 
					
						
							|  |  |  |                          node_allocator_type>::type::value || | 
					
						
							| 
									
										
										
										
											2018-01-05 17:48:13 +00:00
										 |  |  |                        node_alloc() == x.node_alloc()); | 
					
						
							|  |  |  |           swap(x, boost::unordered::detail::integral_constant<bool, | 
					
						
							|  |  |  |                     functions::nothrow_swappable>()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Only call with nodes allocated with the currect allocator, or
 | 
					
						
							|  |  |  |         // one that is equal to it. (Can't assert because other's
 | 
					
						
							|  |  |  |         // allocators might have already been moved).
 | 
					
						
							|  |  |  |         void move_buckets_from(table& other) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           buckets_ = boost::move(other.buckets_); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           size_ = other.size_; | 
					
						
							|  |  |  |           max_load_ = other.max_load_; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           other.size_ = 0; | 
					
						
							|  |  |  |           other.max_load_ = 0; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 10:54:23 +01:00
										 |  |  |         // For use in the constructor when allocators might be different.
 | 
					
						
							|  |  |  |         void move_construct_buckets(table& src) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (this->node_alloc() == src.node_alloc()) { | 
					
						
							|  |  |  |             move_buckets_from(src); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             return; | 
					
						
							| 
									
										
										
										
											2017-10-05 10:54:23 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (src.size_ == 0) { | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT( | 
					
						
							|  |  |  |             buckets_.bucket_count() == src.buckets_.bucket_count()); | 
					
						
							| 
									
										
										
										
											2017-05-06 04:58:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           this->reserve(src.size_); | 
					
						
							|  |  |  |           for (iterator pos = src.begin(); pos != src.end(); ++pos) { | 
					
						
							|  |  |  |             node_tmp b(detail::func::construct_node( | 
					
						
							|  |  |  |                          this->node_alloc(), boost::move(pos.p->value())), | 
					
						
							|  |  |  |               this->node_alloc()); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             const_key_type& k = this->get_key(b.node_); | 
					
						
							|  |  |  |             std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             bucket_iterator itb = | 
					
						
							|  |  |  |               buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |             buckets_.insert_node(itb, b.release()); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         // Delete/destruct
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         ~table() { delete_buckets(); } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void delete_node(node_pointer p) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_allocator_type alloc = this->node_alloc(); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           value_allocator val_alloc(alloc); | 
					
						
							|  |  |  |           boost::allocator_destroy(val_alloc, p->value_ptr()); | 
					
						
							|  |  |  |           boost::allocator_deallocate(alloc, p, 1); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void delete_buckets() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           iterator pos = begin(), last = this->end(); | 
					
						
							|  |  |  |           for (; pos != last;) { | 
					
						
							|  |  |  |             node_pointer p = pos.p; | 
					
						
							|  |  |  |             bucket_iterator itb = pos.itb; | 
					
						
							|  |  |  |             ++pos; | 
					
						
							|  |  |  |             buckets_.extract_node(itb, p); | 
					
						
							|  |  |  |             delete_node(p); | 
					
						
							|  |  |  |             --size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           buckets_.clear(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Clear
 | 
					
						
							| 
									
										
										
										
											2017-05-06 04:58:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void clear_impl(); | 
					
						
							| 
									
										
										
										
											2017-05-06 04:58:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Assignment
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename UniqueType> | 
					
						
							|  |  |  |         void assign(table const& x, UniqueType is_unique) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           typedef typename boost::allocator_propagate_on_container_copy_assignment<node_allocator_type>::type pocca; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           if (this != &x) { | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:44 +01:00
										 |  |  |             assign(x, is_unique, | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               boost::unordered::detail::integral_constant<bool, | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |                 pocca::value>()); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename UniqueType> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void assign(table const &x, UniqueType is_unique, false_type) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           // Strong exception safety.
 | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |           this->construct_spare_functions(x.current_functions()); | 
					
						
							|  |  |  |           BOOST_TRY | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             mlf_ = x.mlf_; | 
					
						
							|  |  |  |             recalculate_max_load(); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             this->reserve_for_insert(x.size_); | 
					
						
							|  |  |  |             this->clear_impl(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |           BOOST_CATCH(...) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             this->cleanup_spare_functions(); | 
					
						
							|  |  |  |             BOOST_RETHROW | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH_END | 
					
						
							|  |  |  |           this->switch_functions(); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           copy_buckets(x, is_unique); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename UniqueType> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void assign(table const &x, UniqueType is_unique, true_type) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (node_alloc() == x.node_alloc()) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             buckets_.reset_allocator(x.node_alloc()); | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:44 +01:00
										 |  |  |             assign(x, is_unique, false_type()); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           } | 
					
						
							|  |  |  |           else | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             bucket_array_type new_buckets(x.size_, x.node_alloc()); | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |             this->construct_spare_functions(x.current_functions()); | 
					
						
							|  |  |  |             this->switch_functions(); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |             // Delete everything with current allocators before assigning
 | 
					
						
							|  |  |  |             // the new ones.
 | 
					
						
							|  |  |  |             delete_buckets(); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             buckets_.reset_allocator(x.node_alloc()); | 
					
						
							|  |  |  |             buckets_ = boost::move(new_buckets); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // Copy over other data, all no throw.
 | 
					
						
							|  |  |  |             mlf_ = x.mlf_; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             reserve(x.size_); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // Finally copy the elements.
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             if (x.size_) | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               copy_buckets(x, is_unique); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename UniqueType> | 
					
						
							|  |  |  |         void move_assign(table& x, UniqueType is_unique) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (this != &x) { | 
					
						
							|  |  |  |             move_assign(x, is_unique, | 
					
						
							|  |  |  |               boost::unordered::detail::integral_constant<bool, | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |                 boost::allocator_propagate_on_container_move_assignment< | 
					
						
							|  |  |  |                   node_allocator_type>::type::value>()); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |         // Propagate allocator
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename UniqueType> | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |         void move_assign(table& x, UniqueType, true_type) | 
					
						
							| 
									
										
										
										
											2018-01-05 17:54:44 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |           if (!functions::nothrow_move_assignable) { | 
					
						
							|  |  |  |             this->construct_spare_functions(x.current_functions()); | 
					
						
							|  |  |  |             this->switch_functions(); | 
					
						
							|  |  |  |           } else { | 
					
						
							|  |  |  |             this->current_functions().move_assign(x.current_functions()); | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2018-01-05 17:54:44 +00:00
										 |  |  |           delete_buckets(); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           buckets_.reset_allocator(x.buckets_.get_node_allocator()); | 
					
						
							| 
									
										
										
										
											2018-01-05 17:54:44 +00:00
										 |  |  |           mlf_ = x.mlf_; | 
					
						
							|  |  |  |           move_buckets_from(x); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // Don't propagate allocator
 | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |         template <typename UniqueType> | 
					
						
							|  |  |  |         void move_assign(table& x, UniqueType is_unique, false_type) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           reserve(x.size_); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           if (node_alloc() == x.node_alloc()) { | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |             move_assign_equal_alloc(x); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } else { | 
					
						
							| 
									
										
										
										
											2018-01-05 17:54:44 +00:00
										 |  |  |             move_assign_realloc(x, is_unique); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |         void move_assign_equal_alloc(table& x) | 
					
						
							| 
									
										
										
										
											2018-01-05 17:54:44 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |           if (!functions::nothrow_move_assignable) { | 
					
						
							|  |  |  |             this->construct_spare_functions(x.current_functions()); | 
					
						
							|  |  |  |             this->switch_functions(); | 
					
						
							|  |  |  |           } else { | 
					
						
							|  |  |  |             this->current_functions().move_assign(x.current_functions()); | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2018-01-05 17:54:44 +00:00
										 |  |  |           delete_buckets(); | 
					
						
							|  |  |  |           mlf_ = x.mlf_; | 
					
						
							|  |  |  |           move_buckets_from(x); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <typename UniqueType> | 
					
						
							|  |  |  |         void move_assign_realloc(table& x, UniqueType is_unique) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |           this->construct_spare_functions(x.current_functions()); | 
					
						
							|  |  |  |           BOOST_TRY | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             mlf_ = x.mlf_; | 
					
						
							|  |  |  |             recalculate_max_load(); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             this->reserve_for_insert(x.size_); | 
					
						
							|  |  |  |             this->clear_impl(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2018-01-06 12:53:37 +00:00
										 |  |  |           BOOST_CATCH(...) | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             this->cleanup_spare_functions(); | 
					
						
							|  |  |  |             BOOST_RETHROW | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           BOOST_CATCH_END | 
					
						
							|  |  |  |           this->switch_functions(); | 
					
						
							| 
									
										
										
										
											2018-01-05 17:54:44 +00:00
										 |  |  |           move_assign_buckets(x, is_unique); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Accessors
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         const_key_type& get_key(node_pointer n) const | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return extractor::extract(n->value()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class Key> | 
					
						
							|  |  |  |         std::size_t hash(Key const& k) const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return this->hash_function()(k); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Find Node
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class Key> | 
					
						
							|  |  |  |         node_pointer find_node_impl( | 
					
						
							|  |  |  |           Key const& x, bucket_iterator itb) const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           key_equal const& pred = this->key_eq(); | 
					
						
							|  |  |  |           node_pointer p = itb->next; | 
					
						
							|  |  |  |           for (; p; p = p->next) { | 
					
						
							|  |  |  |             if (pred(x, extractor::extract(p->value()))) { | 
					
						
							|  |  |  |               break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           return p; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class Key> node_pointer find_node(Key const& k) const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           std::size_t const key_hash = this->hash(k); | 
					
						
							|  |  |  |           return find_node_impl( | 
					
						
							|  |  |  |             k, buckets_.at(buckets_.position(key_hash))); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         node_pointer find_node( | 
					
						
							|  |  |  |           const_key_type& k, bucket_iterator itb) const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return find_node_impl(k, itb); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class Key> iterator find(Key const& k) const | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return this->transparent_find( | 
					
						
							|  |  |  |             k, this->hash_function(), this->key_eq()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | #if defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #pragma warning(push)
 | 
					
						
							|  |  |  | #pragma warning(                                                               \
 | 
					
						
							|  |  |  |   disable : 4714) // function 'function' marked as __forceinline not inlined
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |         template <class Key, class Hash, class Pred> | 
					
						
							|  |  |  |         BOOST_FORCEINLINE iterator transparent_find( | 
					
						
							|  |  |  |           Key const& k, Hash const& h, Pred const& pred) const | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           std::size_t const key_hash = h(k); | 
					
						
							|  |  |  |           bucket_iterator itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |           for (node_pointer p = itb->next; p; p = p->next) { | 
					
						
							|  |  |  |             if (BOOST_LIKELY(pred(k, extractor::extract(p->value())))) { | 
					
						
							|  |  |  |               return iterator(p, itb); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           return this->end(); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | #if defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #pragma warning(pop)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <class Key> | 
					
						
							|  |  |  |         node_pointer* find_prev(Key const& key, bucket_iterator itb) | 
					
						
							| 
									
										
										
										
											2021-12-02 15:30:17 -08:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           key_equal pred = this->key_eq(); | 
					
						
							|  |  |  |           for (node_pointer* pp = boost::addressof(itb->next); *pp; | 
					
						
							|  |  |  |                pp = boost::addressof((*pp)->next)) { | 
					
						
							|  |  |  |             if (pred(key, extractor::extract((*pp)->value()))) { | 
					
						
							|  |  |  |               return pp; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           typedef node_pointer* node_pointer_pointer; | 
					
						
							|  |  |  |           return node_pointer_pointer(); | 
					
						
							| 
									
										
										
										
											2021-12-02 15:30:17 -08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Extract and erase
 | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-03 15:10:59 -08:00
										 |  |  |         template <class Key> node_pointer extract_by_key_impl(Key const& k) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           iterator it = this->find(k); | 
					
						
							|  |  |  |           if (it == this->end()) { | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |             return node_pointer(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           buckets_.extract_node(it.itb, it.p); | 
					
						
							|  |  |  |           --size_; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return it.p; | 
					
						
							| 
									
										
										
										
											2021-12-03 15:10:59 -08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Reserve and rehash
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void transfer_node( | 
					
						
							|  |  |  |           node_pointer p, bucket_type&, bucket_array_type& new_buckets) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           const_key_type& key = extractor::extract(p->value()); | 
					
						
							|  |  |  |           std::size_t const h = this->hash(key); | 
					
						
							|  |  |  |           bucket_iterator itnewb = new_buckets.at(new_buckets.position(h)); | 
					
						
							|  |  |  |           new_buckets.insert_node(itnewb, p); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void rehash(std::size_t); | 
					
						
							|  |  |  |         void reserve(std::size_t); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void reserve_for_insert(std::size_t); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void rehash_impl(std::size_t); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Unique keys
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // equals
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         bool equals_unique(table const& other) const | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (this->size_ != other.size_) | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           c_iterator pos = this->begin(); | 
					
						
							|  |  |  |           c_iterator last = this->end(); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           while (pos != last) { | 
					
						
							|  |  |  |             node_pointer p = pos.p; | 
					
						
							|  |  |  |             node_pointer p2 = other.find_node(this->get_key(p)); | 
					
						
							|  |  |  |             if (!p2 || !(p->value() == p2->value())) { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               return false; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             } | 
					
						
							|  |  |  |             ++pos; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return true; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Emplace/Insert
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <BOOST_UNORDERED_EMPLACE_TEMPLATE> | 
					
						
							|  |  |  |         iterator emplace_hint_unique( | 
					
						
							|  |  |  |           c_iterator hint, const_key_type& k, BOOST_UNORDERED_EMPLACE_ARGS) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (hint.p && this->key_eq()(k, this->get_key(hint.p))) { | 
					
						
							|  |  |  |             return iterator(hint.p, hint.itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } else { | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             return emplace_unique(k, BOOST_UNORDERED_EMPLACE_FORWARD).first; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <BOOST_UNORDERED_EMPLACE_TEMPLATE> | 
					
						
							|  |  |  |         emplace_return emplace_unique( | 
					
						
							|  |  |  |           const_key_type& k, BOOST_UNORDERED_EMPLACE_ARGS) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |           node_pointer pos = this->find_node_impl(k, itb); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           if (pos) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             return emplace_return(iterator(pos, itb), false); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } else { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             node_tmp b(boost::unordered::detail::func::construct_node_from_args( | 
					
						
							|  |  |  |                          this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD), | 
					
						
							|  |  |  |               this->node_alloc()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |               reserve(size_ + 1); | 
					
						
							|  |  |  |               itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_pointer p = b.release(); | 
					
						
							|  |  |  |             buckets_.insert_node(itb, p); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return emplace_return(iterator(p, itb), true); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <BOOST_UNORDERED_EMPLACE_TEMPLATE> | 
					
						
							|  |  |  |         iterator emplace_hint_unique( | 
					
						
							|  |  |  |           c_iterator hint, no_key, BOOST_UNORDERED_EMPLACE_ARGS) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_tmp b(boost::unordered::detail::func::construct_node_from_args( | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |                        this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD), | 
					
						
							|  |  |  |             this->node_alloc()); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           const_key_type& k = this->get_key(b.node_); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (hint.p && this->key_eq()(k, this->get_key(hint.p))) { | 
					
						
							|  |  |  |             return iterator(hint.p, hint.itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           std::size_t const key_hash = this->hash(k); | 
					
						
							|  |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           node_pointer p = this->find_node_impl(k, itb); | 
					
						
							|  |  |  |           if (p) { | 
					
						
							|  |  |  |             return iterator(p, itb); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |             this->reserve(size_ + 1); | 
					
						
							|  |  |  |             itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           p = b.release(); | 
					
						
							|  |  |  |           buckets_.insert_node(itb, p); | 
					
						
							|  |  |  |           ++size_; | 
					
						
							|  |  |  |           return iterator(p, itb); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <BOOST_UNORDERED_EMPLACE_TEMPLATE> | 
					
						
							|  |  |  |         emplace_return emplace_unique(no_key, BOOST_UNORDERED_EMPLACE_ARGS) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_tmp b(boost::unordered::detail::func::construct_node_from_args( | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |                        this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD), | 
					
						
							|  |  |  |             this->node_alloc()); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           const_key_type& k = this->get_key(b.node_); | 
					
						
							|  |  |  |           std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |           node_pointer pos = this->find_node_impl(k, itb); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           if (pos) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             return emplace_return(iterator(pos, itb), false); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } else { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |               reserve(size_ + 1); | 
					
						
							|  |  |  |               itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_pointer p = b.release(); | 
					
						
							|  |  |  |             buckets_.insert_node(itb, p); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return emplace_return(iterator(p, itb), true); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Key> | 
					
						
							|  |  |  |         emplace_return try_emplace_unique(BOOST_FWD_REF(Key) k) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           node_pointer pos = this->find_node_impl(k, itb); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           if (pos) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             return emplace_return(iterator(pos, itb), false); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } else { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             node_allocator_type alloc = node_alloc(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_tmp tmp( | 
					
						
							|  |  |  |               detail::func::construct_node_pair(alloc, boost::forward<Key>(k)), | 
					
						
							|  |  |  |               alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |               reserve(size_ + 1); | 
					
						
							|  |  |  |               itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_pointer p = tmp.release(); | 
					
						
							|  |  |  |             buckets_.insert_node(itb, p); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             ++size_; | 
					
						
							|  |  |  |             return emplace_return(iterator(p, itb), true); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Key> | 
					
						
							|  |  |  |         iterator try_emplace_hint_unique(c_iterator hint, BOOST_FWD_REF(Key) k) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (hint.p && this->key_eq()(hint->first, k)) { | 
					
						
							|  |  |  |             return iterator(hint.p, hint.itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } else { | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             return try_emplace_unique(k).first; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Key, BOOST_UNORDERED_EMPLACE_TEMPLATE> | 
					
						
							|  |  |  |         emplace_return try_emplace_unique( | 
					
						
							|  |  |  |           BOOST_FWD_REF(Key) k, BOOST_UNORDERED_EMPLACE_ARGS) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           node_pointer pos = this->find_node_impl(k, itb); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           if (pos) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             return emplace_return(iterator(pos, itb), false); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           node_tmp b( | 
					
						
							|  |  |  |             boost::unordered::detail::func::construct_node_pair_from_args( | 
					
						
							|  |  |  |               this->node_alloc(), k, BOOST_UNORDERED_EMPLACE_FORWARD), | 
					
						
							|  |  |  |             this->node_alloc()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |             reserve(size_ + 1); | 
					
						
							|  |  |  |             itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           pos = b.release(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           buckets_.insert_node(itb, pos); | 
					
						
							|  |  |  |           ++size_; | 
					
						
							|  |  |  |           return emplace_return(iterator(pos, itb), true); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Key, BOOST_UNORDERED_EMPLACE_TEMPLATE> | 
					
						
							|  |  |  |         iterator try_emplace_hint_unique( | 
					
						
							|  |  |  |           c_iterator hint, BOOST_FWD_REF(Key) k, BOOST_UNORDERED_EMPLACE_ARGS) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (hint.p && this->key_eq()(hint->first, k)) { | 
					
						
							|  |  |  |             return iterator(hint.p, hint.itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } else { | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             return try_emplace_unique(k, BOOST_UNORDERED_EMPLACE_FORWARD).first; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Key, typename M> | 
					
						
							|  |  |  |         emplace_return insert_or_assign_unique( | 
					
						
							|  |  |  |           BOOST_FWD_REF(Key) k, BOOST_FWD_REF(M) obj) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           node_pointer p = this->find_node_impl(k, itb); | 
					
						
							|  |  |  |           if (p) { | 
					
						
							|  |  |  |             p->value().second = boost::forward<M>(obj); | 
					
						
							|  |  |  |             return emplace_return(iterator(p, itb), false); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           node_tmp b(boost::unordered::detail::func::construct_node_pair( | 
					
						
							|  |  |  |                        this->node_alloc(), boost::forward<Key>(k), | 
					
						
							|  |  |  |                        boost::forward<M>(obj)), | 
					
						
							|  |  |  |             node_alloc()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |             reserve(size_ + 1); | 
					
						
							|  |  |  |             itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           p = b.release(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           buckets_.insert_node(itb, p); | 
					
						
							|  |  |  |           ++size_; | 
					
						
							|  |  |  |           return emplace_return(iterator(p, itb), true); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename NodeType, typename InsertReturnType> | 
					
						
							|  |  |  |         void move_insert_node_type_unique( | 
					
						
							|  |  |  |           NodeType& np, InsertReturnType& result) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (!np) { | 
					
						
							|  |  |  |             result.position = this->end(); | 
					
						
							|  |  |  |             result.inserted = false; | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           const_key_type& k = this->get_key(np.ptr_); | 
					
						
							|  |  |  |           std::size_t const key_hash = this->hash(k); | 
					
						
							|  |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |           node_pointer p = this->find_node_impl(k, itb); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (p) { | 
					
						
							|  |  |  |             iterator pos(p, itb); | 
					
						
							|  |  |  |             result.node = boost::move(np); | 
					
						
							|  |  |  |             result.position = pos; | 
					
						
							|  |  |  |             result.inserted = false; | 
					
						
							|  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           this->reserve_for_insert(size_ + 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           p = np.ptr_; | 
					
						
							|  |  |  |           itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           buckets_.insert_node(itb, p); | 
					
						
							|  |  |  |           np.ptr_ = node_pointer(); | 
					
						
							|  |  |  |           ++size_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           result.position = iterator(p, itb); | 
					
						
							|  |  |  |           result.inserted = true; | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename NodeType> | 
					
						
							|  |  |  |         iterator move_insert_node_type_with_hint_unique( | 
					
						
							|  |  |  |           c_iterator hint, NodeType& np) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (!np) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             return this->end(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           const_key_type& k = this->get_key(np.ptr_); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (hint.p && this->key_eq()(k, this->get_key(hint.p))) { | 
					
						
							|  |  |  |             return iterator(hint.p, hint.itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           std::size_t const key_hash = this->hash(k); | 
					
						
							|  |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |           node_pointer p = this->find_node_impl(k, itb); | 
					
						
							|  |  |  |           if (p) { | 
					
						
							|  |  |  |             return iterator(p, itb); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           p = np.ptr_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |             this->reserve(size_ + 1); | 
					
						
							|  |  |  |             itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           buckets_.insert_node(itb, p); | 
					
						
							|  |  |  |           ++size_; | 
					
						
							|  |  |  |           np.ptr_ = node_pointer(); | 
					
						
							|  |  |  |           return iterator(p, itb); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename Types2> | 
					
						
							|  |  |  |         void merge_unique(boost::unordered::detail::table<Types2>& other) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           typedef boost::unordered::detail::table<Types2> other_table; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_STATIC_ASSERT((boost::is_same<node_type, | 
					
						
							|  |  |  |             typename other_table::node_type>::value)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           BOOST_ASSERT(this->node_alloc() == other.node_alloc()); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (other.size_ == 0) { | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           this->reserve_for_insert(size_ + other.size_); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           iterator last = other.end(); | 
					
						
							|  |  |  |           for (iterator pos = other.begin(); pos != last;) { | 
					
						
							|  |  |  |             const_key_type& key = other.get_key(pos.p); | 
					
						
							|  |  |  |             std::size_t const key_hash = this->hash(key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bucket_iterator itb = | 
					
						
							|  |  |  |               buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (this->find_node_impl(key, itb)) { | 
					
						
							|  |  |  |               ++pos; | 
					
						
							|  |  |  |               continue; | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |             iterator old = pos; | 
					
						
							|  |  |  |             ++pos; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_pointer p = other.extract_by_iterator_unique(old); | 
					
						
							|  |  |  |             buckets_.insert_node(itb, p); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Insert range methods
 | 
					
						
							|  |  |  |         //
 | 
					
						
							|  |  |  |         // if hash function throws, or inserting > 1 element, basic exception
 | 
					
						
							|  |  |  |         // safety strong otherwise
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class InputIt> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         void insert_range_unique(no_key, InputIt i, InputIt j) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           hasher const& hf = this->hash_function(); | 
					
						
							|  |  |  |           node_allocator_type alloc = this->node_alloc(); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           for (; i != j; ++i) { | 
					
						
							|  |  |  |             node_tmp tmp(detail::func::construct_node(alloc, *i), alloc); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             value_type const& value = tmp.node_->value(); | 
					
						
							|  |  |  |             const_key_type& key = extractor::extract(value); | 
					
						
							|  |  |  |             std::size_t const h = hf(key); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             bucket_iterator itb = buckets_.at(buckets_.position(h)); | 
					
						
							|  |  |  |             node_pointer it = find_node_impl(key, itb); | 
					
						
							|  |  |  |             if (it) { | 
					
						
							|  |  |  |               continue; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |               reserve(size_ + 1); | 
					
						
							|  |  |  |               itb = buckets_.at(buckets_.position(h)); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |             node_pointer nptr = tmp.release(); | 
					
						
							|  |  |  |             buckets_.insert_node(itb, nptr); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Extract
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         inline node_pointer extract_by_iterator_unique(c_iterator i) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           node_pointer p = i.p; | 
					
						
							|  |  |  |           bucket_iterator itb = i.itb; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           buckets_.extract_node(itb, p); | 
					
						
							|  |  |  |           --size_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           return p; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Erase
 | 
					
						
							|  |  |  |         //
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class Key> std::size_t erase_key_unique_impl(Key const& k) | 
					
						
							| 
									
										
										
										
											2021-12-02 15:44:02 -08:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = buckets_.at(buckets_.position(this->hash(k))); | 
					
						
							|  |  |  |           node_pointer* pp = this->find_prev(k, itb); | 
					
						
							|  |  |  |           if (!pp) { | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             return 0; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2021-12-02 15:44:02 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           node_pointer p = *pp; | 
					
						
							|  |  |  |           buckets_.extract_node_after(itb, pp); | 
					
						
							|  |  |  |           this->delete_node(p); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           --size_; | 
					
						
							| 
									
										
										
										
											2021-12-02 15:44:02 -08:00
										 |  |  |           return 1; | 
					
						
							| 
									
										
										
										
											2021-12-02 15:38:07 -08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         iterator erase_nodes_range(c_iterator first, c_iterator last) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           if (first == last) { | 
					
						
							|  |  |  |             return iterator(last.p, last.itb); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           // though `first` stores of a copy of a pointer to a node, we wish to
 | 
					
						
							|  |  |  |           // mutate the pointers stored internally by the singly-linked list in
 | 
					
						
							|  |  |  |           // each bucket group so we have to retrieve it manually by iterating
 | 
					
						
							|  |  |  |           //
 | 
					
						
							|  |  |  |           bucket_iterator itb = first.itb; | 
					
						
							|  |  |  |           node_pointer* pp = boost::addressof(itb->next); | 
					
						
							|  |  |  |           while (*pp != first.p) { | 
					
						
							|  |  |  |             pp = boost::addressof((*pp)->next); | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           while (*pp != last.p) { | 
					
						
							|  |  |  |             node_pointer p = *pp; | 
					
						
							|  |  |  |             *pp = (*pp)->next; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             this->delete_node(p); | 
					
						
							| 
									
										
										
										
											2017-05-03 23:37:42 +01:00
										 |  |  |             --size_; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bool const at_end = !(*pp); | 
					
						
							|  |  |  |             bool const is_empty_bucket = !itb->next; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (at_end) { | 
					
						
							|  |  |  |               if (is_empty_bucket) { | 
					
						
							|  |  |  |                 buckets_.unlink_bucket(itb++); | 
					
						
							|  |  |  |               } else { | 
					
						
							|  |  |  |                 ++itb; | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |               pp = boost::addressof(itb->next); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           return iterator(last.p, last.itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // fill_buckets_unique
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void copy_buckets(table const& src, true_type) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(size_ == 0); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           this->reserve_for_insert(src.size_); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           for (iterator pos = src.begin(); pos != src.end(); ++pos) { | 
					
						
							|  |  |  |             value_type const& value = *pos; | 
					
						
							|  |  |  |             const_key_type& key = extractor::extract(value); | 
					
						
							|  |  |  |             std::size_t const key_hash = this->hash(key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bucket_iterator itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_allocator_type alloc = this->node_alloc(); | 
					
						
							|  |  |  |             node_tmp tmp(detail::func::construct_node(alloc, value), alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             buckets_.insert_node(itb, tmp.release()); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void move_assign_buckets(table& src, true_type) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(size_ == 0); | 
					
						
							|  |  |  |           BOOST_ASSERT(max_load_ >= src.size_); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           iterator last = src.end(); | 
					
						
							|  |  |  |           node_allocator_type alloc = this->node_alloc(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           for (iterator pos = src.begin(); pos != last; ++pos) { | 
					
						
							|  |  |  |             value_type value = boost::move(*pos); | 
					
						
							|  |  |  |             const_key_type& key = extractor::extract(value); | 
					
						
							|  |  |  |             std::size_t const key_hash = this->hash(key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bucket_iterator itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_tmp tmp( | 
					
						
							|  |  |  |               detail::func::construct_node(alloc, boost::move(value)), alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             buckets_.insert_node(itb, tmp.release()); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Equivalent keys
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Equality
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         bool equals_equiv(table const& other) const | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (this->size_ != other.size_) | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             return false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           iterator last = this->end(); | 
					
						
							|  |  |  |           for (iterator n1 = this->begin(); n1 != last;) { | 
					
						
							|  |  |  |             const_key_type& k = extractor::extract(*n1); | 
					
						
							|  |  |  |             iterator n2 = other.find(k); | 
					
						
							|  |  |  |             if (n2 == other.end()) { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               return false; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             iterator end1 = this->next_group(k, n1); | 
					
						
							|  |  |  |             iterator end2 = other.next_group(k, n2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (!group_equals_equiv(n1, end1, n2, end2)) { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               return false; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             n1 = end1; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return true; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         static bool group_equals_equiv(iterator n1, iterator end1, | 
					
						
							|  |  |  |           iterator n2, iterator end2) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           for (;;) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             if (*n1 != *n2) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               break; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             ++n1; | 
					
						
							|  |  |  |             ++n2; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (n1 == end1) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               return n2 == end2; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             if (n2 == end2) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               return false; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           for (iterator n1a = n1, n2a = n2;;) { | 
					
						
							|  |  |  |             ++n1a; | 
					
						
							|  |  |  |             ++n2a; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (n1a == end1) { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               if (n2a == end2) | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |               else | 
					
						
							|  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (n2a == end2) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               return false; | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           iterator start = n1; | 
					
						
							|  |  |  |           for (; n1 != end1; ++n1) { | 
					
						
							|  |  |  |             value_type const& v = *n1; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             if (!find_equiv(start, n1, v)) { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               std::size_t matches = count_equal_equiv(n2, end2, v); | 
					
						
							|  |  |  |               if (!matches) | 
					
						
							|  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |               iterator t = n1; | 
					
						
							|  |  |  |               if (matches != 1 + count_equal_equiv(++t, end1, v)) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return true; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         static bool find_equiv( | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           iterator n, iterator last, value_type const& v) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           for (; n != last; ++n) | 
					
						
							|  |  |  |             if (*n == v) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               return true; | 
					
						
							|  |  |  |           return false; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         static std::size_t count_equal_equiv( | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           iterator n, iterator last, value_type const& v) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           std::size_t count = 0; | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           for (; n != last; ++n) | 
					
						
							|  |  |  |             if (*n == v) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               ++count; | 
					
						
							|  |  |  |           return count; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // Emplace/Insert
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         iterator emplace_equiv(node_pointer n) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_tmp a(n, this->node_alloc()); | 
					
						
							|  |  |  |           const_key_type& k = this->get_key(a.node_); | 
					
						
							|  |  |  |           std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = | 
					
						
							|  |  |  |             buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |           node_pointer hint = this->find_node_impl(k, itb); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |             this->reserve(size_ + 1); | 
					
						
							|  |  |  |             itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           node_pointer p = a.release(); | 
					
						
							|  |  |  |           buckets_.insert_node_hint(itb, p, hint); | 
					
						
							|  |  |  |           ++size_; | 
					
						
							|  |  |  |           return iterator(p, itb); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         iterator emplace_hint_equiv(c_iterator hint, node_pointer n) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           node_tmp a(n, this->node_alloc()); | 
					
						
							|  |  |  |           const_key_type& k = this->get_key(a.node_); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = hint.itb; | 
					
						
							|  |  |  |           node_pointer p = hint.p; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           std::size_t key_hash = 0u; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           bool const needs_rehash = (size_ + 1 > max_load_); | 
					
						
							|  |  |  |           bool const usable_hint = (p && this->key_eq()(k, this->get_key(p))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (!usable_hint) { | 
					
						
							|  |  |  |             key_hash = this->hash(k); | 
					
						
							|  |  |  |             itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |             p = this->find_node_impl(k, itb); | 
					
						
							|  |  |  |           } else if (usable_hint && needs_rehash) { | 
					
						
							|  |  |  |             key_hash = this->hash(k); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (needs_rehash) { | 
					
						
							|  |  |  |             this->reserve(size_ + 1); | 
					
						
							|  |  |  |             itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           a.release(); | 
					
						
							|  |  |  |           buckets_.insert_node_hint(itb, n, p); | 
					
						
							|  |  |  |           ++size_; | 
					
						
							|  |  |  |           return iterator(n, itb); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void emplace_no_rehash_equiv(node_pointer n) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(size_ + 1 <= max_load_); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           node_tmp a(n, this->node_alloc()); | 
					
						
							|  |  |  |           const_key_type& k = this->get_key(a.node_); | 
					
						
							|  |  |  |           std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |           node_pointer hint = this->find_node_impl(k, itb); | 
					
						
							|  |  |  |           node_pointer p = a.release(); | 
					
						
							|  |  |  |           buckets_.insert_node_hint(itb, p, hint); | 
					
						
							|  |  |  |           ++size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename NodeType> | 
					
						
							|  |  |  |         iterator move_insert_node_type_equiv(NodeType& np) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           iterator result; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           if (np) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             this->reserve_for_insert(size_ + 1); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             const_key_type& k = this->get_key(np.ptr_); | 
					
						
							|  |  |  |             std::size_t key_hash = this->hash(k); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |             bucket_iterator itb = | 
					
						
							|  |  |  |               buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_pointer hint = this->find_node_impl(k, itb); | 
					
						
							|  |  |  |             buckets_.insert_node_hint(itb, np.ptr_, hint); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             result = iterator(np.ptr_, itb); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             np.ptr_ = node_pointer(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return result; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <typename NodeType> | 
					
						
							|  |  |  |         iterator move_insert_node_type_with_hint_equiv( | 
					
						
							|  |  |  |           c_iterator hint, NodeType& np) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           iterator result; | 
					
						
							|  |  |  |           if (np) { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             bucket_iterator itb = hint.itb; | 
					
						
							|  |  |  |             node_pointer pos = hint.p; | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             const_key_type& k = this->get_key(np.ptr_); | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             std::size_t key_hash = this->hash(k); | 
					
						
							|  |  |  |             if (size_ + 1 > max_load_) { | 
					
						
							|  |  |  |               this->reserve(size_ + 1); | 
					
						
							|  |  |  |               itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             if (hint.p && this->key_eq()(k, this->get_key(hint.p))) { | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |               itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |               pos = this->find_node_impl(k, itb); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             buckets_.insert_node_hint(itb, np.ptr_, pos); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							|  |  |  |             result = iterator(np.ptr_, itb); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             np.ptr_ = node_pointer(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return result; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Insert range methods
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         // if hash function throws, or inserting > 1 element, basic exception
 | 
					
						
							|  |  |  |         // safety. Strong otherwise
 | 
					
						
							|  |  |  |         template <class I> | 
					
						
							| 
									
										
										
										
											2021-11-18 12:54:17 -08:00
										 |  |  |         typename boost::unordered::detail::enable_if_forward<I, void>::type | 
					
						
							|  |  |  |         insert_range_equiv(I i, I j) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           if (i == j) | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           std::size_t distance = static_cast<std::size_t>(std::distance(i, j)); | 
					
						
							|  |  |  |           if (distance == 1) { | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             emplace_equiv(boost::unordered::detail::func::construct_node( | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               this->node_alloc(), *i)); | 
					
						
							|  |  |  |           } else { | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             // Only require basic exception safety here
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |             this->reserve_for_insert(size_ + distance); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             for (; i != j; ++i) { | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               emplace_no_rehash_equiv( | 
					
						
							|  |  |  |                 boost::unordered::detail::func::construct_node( | 
					
						
							|  |  |  |                   this->node_alloc(), *i)); | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class I> | 
					
						
							| 
									
										
										
										
											2021-11-18 12:54:17 -08:00
										 |  |  |         typename boost::unordered::detail::disable_if_forward<I, void>::type | 
					
						
							|  |  |  |         insert_range_equiv(I i, I j) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           for (; i != j; ++i) { | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             emplace_equiv(boost::unordered::detail::func::construct_node( | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |               this->node_alloc(), *i)); | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Extract
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         inline node_pointer extract_by_iterator_equiv(c_iterator n) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           node_pointer p = n.p; | 
					
						
							|  |  |  |           bucket_iterator itb = n.itb; | 
					
						
							|  |  |  |           buckets_.extract_node(itb, p); | 
					
						
							|  |  |  |           --size_; | 
					
						
							|  |  |  |           return p; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // Erase
 | 
					
						
							|  |  |  |         //
 | 
					
						
							|  |  |  |         // no throw
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         template <class Key> std::size_t erase_key_equiv_impl(Key const& k) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           std::size_t deleted_count = 0; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_iterator itb = buckets_.at(buckets_.position(this->hash(k))); | 
					
						
							|  |  |  |           node_pointer* pp = this->find_prev(k, itb); | 
					
						
							|  |  |  |           if (pp) { | 
					
						
							|  |  |  |             while (*pp && this->key_eq()(this->get_key(*pp), k)) { | 
					
						
							|  |  |  |               node_pointer p = *pp; | 
					
						
							|  |  |  |               *pp = (*pp)->next; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |               this->delete_node(p); | 
					
						
							|  |  |  |               --size_; | 
					
						
							|  |  |  |               ++deleted_count; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (!itb->next) { | 
					
						
							|  |  |  |               buckets_.unlink_bucket(itb); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           return deleted_count; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 09:20:40 -08:00
										 |  |  |         std::size_t erase_key_equiv(const_key_type& k) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           return this->erase_key_equiv_impl(k); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |         // fill_buckets
 | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void copy_buckets(table const& src, false_type) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(size_ == 0); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           this->reserve_for_insert(src.size_); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           iterator last = src.end(); | 
					
						
							|  |  |  |           for (iterator pos = src.begin(); pos != last; ++pos) { | 
					
						
							|  |  |  |             value_type const& value = *pos; | 
					
						
							|  |  |  |             const_key_type& key = extractor::extract(value); | 
					
						
							|  |  |  |             std::size_t const key_hash = this->hash(key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bucket_iterator itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  |             node_allocator_type alloc = this->node_alloc(); | 
					
						
							|  |  |  |             node_tmp tmp(detail::func::construct_node(alloc, value), alloc); | 
					
						
							|  |  |  |             node_pointer hint = this->find_node_impl(key, itb); | 
					
						
							|  |  |  |             buckets_.insert_node_hint(itb, tmp.release(), hint); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         void move_assign_buckets(table& src, false_type) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           BOOST_ASSERT(size_ == 0); | 
					
						
							|  |  |  |           BOOST_ASSERT(max_load_ >= src.size_); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           iterator last = src.end(); | 
					
						
							|  |  |  |           node_allocator_type alloc = this->node_alloc(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           for (iterator pos = src.begin(); pos != last; ++pos) { | 
					
						
							|  |  |  |             value_type value = boost::move(*pos); | 
					
						
							|  |  |  |             const_key_type& key = extractor::extract(value); | 
					
						
							|  |  |  |             std::size_t const key_hash = this->hash(key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bucket_iterator itb = buckets_.at(buckets_.position(key_hash)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             node_pointer hint = this->find_node_impl(key, itb); | 
					
						
							|  |  |  |             node_tmp tmp( | 
					
						
							|  |  |  |               detail::func::construct_node(alloc, boost::move(value)), alloc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             buckets_.insert_node_hint(itb, tmp.release(), hint); | 
					
						
							|  |  |  |             ++size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       // Clear
 | 
					
						
							| 
									
										
										
										
											2017-05-06 04:58:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename Types> inline void table<Types>::clear_impl() | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         bucket_iterator itb = buckets_.begin(), last = buckets_.end(); | 
					
						
							|  |  |  |         for (; itb != last;) { | 
					
						
							|  |  |  |           bucket_iterator next_itb = itb; | 
					
						
							|  |  |  |           ++next_itb; | 
					
						
							|  |  |  |           node_pointer* pp = boost::addressof(itb->next); | 
					
						
							|  |  |  |           while (*pp) { | 
					
						
							|  |  |  |             node_pointer p = *pp; | 
					
						
							|  |  |  |             buckets_.extract_node_after(itb, pp); | 
					
						
							|  |  |  |             this->delete_node(p); | 
					
						
							|  |  |  |             --size_; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           itb = next_itb; | 
					
						
							| 
									
										
										
										
											2017-05-06 04:58:57 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       //////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       // Reserve & Rehash
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       // if hash function throws, basic exception safety
 | 
					
						
							|  |  |  |       // strong otherwise.
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <typename Types> | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       inline void table<Types>::rehash(std::size_t num_buckets) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         std::size_t bc = (std::max)(num_buckets, | 
					
						
							|  |  |  |           static_cast<std::size_t>(1.0f + static_cast<float>(size_) / mlf_)); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         if (bc <= buckets_.bucket_count()) { | 
					
						
							|  |  |  |           return; | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         this->rehash_impl(bc); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       template <class Types> | 
					
						
							|  |  |  |       inline void table<Types>::reserve(std::size_t num_elements) | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         std::size_t const num_buckets = static_cast<std::size_t>( | 
					
						
							|  |  |  |           std::ceil(static_cast<float>(num_elements) / mlf_)); | 
					
						
							| 
									
										
										
										
											2017-02-27 03:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         this->rehash(num_buckets); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <class Types> | 
					
						
							|  |  |  |       inline void table<Types>::reserve_for_insert(std::size_t num_elements) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         if (num_elements > max_load_) { | 
					
						
							|  |  |  |           std::size_t const num_buckets = static_cast<std::size_t>( | 
					
						
							|  |  |  |             1.0f + std::ceil(static_cast<float>(num_elements) / mlf_)); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           this->rehash_impl(num_buckets); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |       template <class Types> | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       inline void table<Types>::rehash_impl(std::size_t num_buckets) | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         bucket_array_type new_buckets( | 
					
						
							|  |  |  |           num_buckets, buckets_.get_node_allocator()); | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_TRY | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           boost::unordered::detail::span<bucket_type> bspan = buckets_.raw(); | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           bucket_type* pos = bspan.data; | 
					
						
							|  |  |  |           std::size_t size = bspan.size; | 
					
						
							|  |  |  |           bucket_type* last = pos + size; | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           for (; pos != last; ++pos) { | 
					
						
							|  |  |  |             bucket_type& b = *pos; | 
					
						
							|  |  |  |             for (node_pointer p = b.next; p;) { | 
					
						
							|  |  |  |               node_pointer next_p = p->next; | 
					
						
							|  |  |  |               transfer_node(p, b, new_buckets); | 
					
						
							|  |  |  |               p = next_p; | 
					
						
							|  |  |  |               b.next = p; | 
					
						
							| 
									
										
										
										
											2017-04-27 18:22:44 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_CATCH(...) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           for (bucket_iterator pos = new_buckets.begin(); | 
					
						
							|  |  |  |                pos != new_buckets.end(); ++pos) { | 
					
						
							|  |  |  |             bucket_type& b = *pos; | 
					
						
							|  |  |  |             for (node_pointer p = b.next; p;) { | 
					
						
							|  |  |  |               node_pointer next_p = p->next; | 
					
						
							|  |  |  |               delete_node(p); | 
					
						
							|  |  |  |               --size_; | 
					
						
							|  |  |  |               p = next_p; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |           buckets_.unlink_empty_buckets(); | 
					
						
							|  |  |  |           BOOST_RETHROW; | 
					
						
							| 
									
										
										
										
											2017-05-06 04:58:57 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_CATCH_END | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         buckets_ = boost::move(new_buckets); | 
					
						
							|  |  |  |         recalculate_max_load(); | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #if defined(BOOST_MSVC)
 | 
					
						
							|  |  |  | #pragma warning(pop)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       ////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |       // key extractors
 | 
					
						
							|  |  |  |       //
 | 
					
						
							|  |  |  |       // no throw
 | 
					
						
							|  |  |  |       //
 | 
					
						
							|  |  |  |       // 'extract_key' is called with the emplace parameters to return a
 | 
					
						
							|  |  |  |       // key if available or 'no_key' is one isn't and will need to be
 | 
					
						
							|  |  |  |       // constructed. This could be done by overloading the emplace
 | 
					
						
							|  |  |  |       // implementation
 | 
					
						
							|  |  |  |       // for the different cases, but that's a bit tricky on compilers without
 | 
					
						
							|  |  |  |       // variadic templates.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template <typename Key, typename T> struct is_key | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         template <typename T2> static choice1::type test(T2 const&); | 
					
						
							|  |  |  |         static choice2::type test(Key const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         enum | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           value = sizeof(test(boost::unordered::detail::make<T>())) == | 
					
						
							|  |  |  |                   sizeof(choice2::type) | 
					
						
							|  |  |  |         }; | 
					
						
							| 
									
										
										
										
											2017-05-01 21:03:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         typedef typename boost::detail::if_true<value>::BOOST_NESTED_TEMPLATE | 
					
						
							|  |  |  |           then<Key const&, no_key>::type type; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <class ValueType> struct set_extractor | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef ValueType value_type; | 
					
						
							|  |  |  |         typedef ValueType key_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static key_type const& extract(value_type const& v) { return v; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static key_type const& extract(BOOST_UNORDERED_RV_REF(value_type) v) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return v; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static no_key extract() { return no_key(); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         template <class Arg> static no_key extract(Arg const&) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return no_key(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Arg1, class Arg2, class... Args> | 
					
						
							|  |  |  |         static no_key extract(Arg1 const&, Arg2 const&, Args const&...) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return no_key(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Arg1, class Arg2> | 
					
						
							|  |  |  |         static no_key extract(Arg1 const&, Arg2 const&) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return no_key(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       }; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       template <class ValueType> struct map_extractor | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef ValueType value_type; | 
					
						
							|  |  |  |         typedef typename boost::remove_const<typename boost::unordered::detail:: | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |             pair_traits<ValueType>::first_type>::type key_type; | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         static key_type const& extract(value_type const& v) { return v.first; } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Second> | 
					
						
							|  |  |  |         static key_type const& extract(std::pair<key_type, Second> const& v) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return v.first; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Second> | 
					
						
							|  |  |  |         static key_type const& extract( | 
					
						
							|  |  |  |           std::pair<key_type const, Second> const& v) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return v.first; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-01 21:03:11 +01:00
										 |  |  | #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Second> | 
					
						
							|  |  |  |         static key_type const& extract( | 
					
						
							|  |  |  |           boost::rv<std::pair<key_type, Second> > const& v) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return v.first; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-05-01 21:03:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Second> | 
					
						
							|  |  |  |         static key_type const& extract( | 
					
						
							|  |  |  |           boost::rv<std::pair<key_type const, Second> > const& v) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return v.first; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-05-01 21:03:11 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Arg1> | 
					
						
							|  |  |  |         static key_type const& extract(key_type const& k, Arg1 const&) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return k; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         static no_key extract() { return no_key(); } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Arg> static no_key extract(Arg const&) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return no_key(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Arg1, class Arg2> | 
					
						
							|  |  |  |         static no_key extract(Arg1 const&, Arg2 const&) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return no_key(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         template <class Arg1, class Arg2, class Arg3, class... Args> | 
					
						
							|  |  |  |         static no_key extract( | 
					
						
							|  |  |  |           Arg1 const&, Arg2 const&, Arg3 const&, Args const&...) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           return no_key(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #define BOOST_UNORDERED_KEY_FROM_TUPLE(namespace_)                             \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   template <typename T2>                                                       \ | 
					
						
							|  |  |  |   static no_key extract(boost::unordered::piecewise_construct_t,               \ | 
					
						
							|  |  |  |     namespace_ tuple<> const&, T2 const&)                                      \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     return no_key();                                                           \ | 
					
						
							|  |  |  |   }                                                                            \ | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |                                                                                \ | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   template <typename T, typename T2>                                           \ | 
					
						
							|  |  |  |   static typename is_key<key_type, T>::type extract(                           \ | 
					
						
							|  |  |  |     boost::unordered::piecewise_construct_t, namespace_ tuple<T> const& k,     \ | 
					
						
							|  |  |  |     T2 const&)                                                                 \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     return typename is_key<key_type, T>::type(namespace_ get<0>(k));           \ | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #define BOOST_UNORDERED_KEY_FROM_TUPLE(namespace_)                             \
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   static no_key extract(                                                       \ | 
					
						
							|  |  |  |     boost::unordered::piecewise_construct_t, namespace_ tuple<> const&)        \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     return no_key();                                                           \ | 
					
						
							|  |  |  |   }                                                                            \ | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  |                                                                                \ | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |   template <typename T>                                                        \ | 
					
						
							|  |  |  |   static typename is_key<key_type, T>::type extract(                           \ | 
					
						
							|  |  |  |     boost::unordered::piecewise_construct_t, namespace_ tuple<T> const& k)     \ | 
					
						
							|  |  |  |   {                                                                            \ | 
					
						
							|  |  |  |     return typename is_key<key_type, T>::type(namespace_ get<0>(k));           \ | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_UNORDERED_KEY_FROM_TUPLE(boost::) | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #if BOOST_UNORDERED_TUPLE_ARGS
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |         BOOST_UNORDERED_KEY_FROM_TUPLE(std::) | 
					
						
							| 
									
										
										
										
											2017-04-24 09:46:05 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-04-25 20:20:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_KEY_FROM_TUPLE
 | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-22 15:14:14 -08:00
										 |  |  |       template <class Container, class Predicate> | 
					
						
							|  |  |  |       typename Container::size_type erase_if(Container& c, Predicate& pred) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         typedef typename Container::size_type size_type; | 
					
						
							|  |  |  |         typedef typename Container::iterator iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         size_type const size = c.size(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 14:33:35 -07:00
										 |  |  |         for (iterator pos = c.begin(), last = c.end(); pos != last;) { | 
					
						
							| 
									
										
										
										
											2022-02-22 15:14:14 -08:00
										 |  |  |           if (pred(*pos)) { | 
					
						
							|  |  |  |             pos = c.erase(pos); | 
					
						
							|  |  |  |           } else { | 
					
						
							|  |  |  |             ++pos; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return (size - c.size()); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-06-11 20:55:59 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-25 20:20:11 +01:00
										 |  |  | #undef BOOST_UNORDERED_EMPLACE_TEMPLATE
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_EMPLACE_ARGS
 | 
					
						
							|  |  |  | #undef BOOST_UNORDERED_EMPLACE_FORWARD
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-19 13:05:17 +00:00
										 |  |  | #endif
 |