diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 65592760..d1d11977 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -46,10 +46,76 @@ #include #endif +#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) +#include +#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. + +// BOOST_UNORDERED_EMPLACE_LIMIT = The maximum number of parameters in emplace +// (not including things like hints). Don't set it to a lower value, as that +// might break something. + +#if !defined BOOST_UNORDERED_EMPLACE_LIMIT +#define BOOST_UNORDERED_EMPLACE_LIMIT 11 +#endif + +// BOOST_UNORDERED_USE_ALLOCATOR_TRAITS - Pick which version of +// allocator_traits to use. +// +// 0 = Own partial implementation +// 1 = std::allocator_traits +// 2 = boost::container::allocator_traits + +#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS) +#if !defined(BOOST_NO_CXX11_ALLOCATOR) +#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 1 +#elif defined(BOOST_MSVC) +#if BOOST_MSVC < 1400 +// Use container's allocator_traits for older versions of Visual +// C++ as I don't test with them. +#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 2 +#endif +#endif +#endif + +#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS) +#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 0 +#endif + +namespace boost { +namespace unordered { +namespace iterator_detail { +template struct iterator; +template struct c_iterator; +template struct l_iterator; +template struct cl_iterator; +} +} +} + namespace boost { namespace unordered { namespace detail { +template struct table; +template struct bucket; +struct ptr_bucket; +template struct table_impl; +template struct grouped_table_impl; + +template struct unique_node; +template struct ptr_node; +template struct table_impl; + +template struct grouped_node; +template struct grouped_ptr_node; +template struct grouped_table_impl; + static const float minimum_max_load_factor = 1e-3f; static const std::size_t default_bucket_count = 11; struct move_tag @@ -270,9 +336,6 @@ struct compressed // move_assign explicit. compressed& operator=(compressed const&); }; -} -} -} #if defined(BOOST_MSVC) #pragma warning(push) @@ -282,13 +345,6 @@ struct compressed // will be default-initialized. #endif -// Maximum number of arguments supported by emplace + 1. -#define BOOST_UNORDERED_EMPLACE_LIMIT 11 - -namespace boost { -namespace unordered { -namespace detail { - //////////////////////////////////////////////////////////////////////////// // Bits and pieces for implementing traits @@ -483,33 +539,6 @@ BOOST_PP_REPEAT_FROM_TO( #undef BOOST_UNORDERED_EARGS_MEMBER #undef BOOST_UNORDERED_EARGS_INIT -#endif -} -} -} - -//////////////////////////////////////////////////////////////////////////////// -// -// Pick which version of allocator_traits to use -// -// 0 = Own partial implementation -// 1 = std::allocator_traits -// 2 = boost::container::allocator_traits - -#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS) -#if !defined(BOOST_NO_CXX11_ALLOCATOR) -#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 1 -#elif defined(BOOST_MSVC) -#if BOOST_MSVC < 1400 -// Use container's allocator_traits for older versions of Visual -// C++ as I don't test with them. -#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 2 -#endif -#endif -#endif - -#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS) -#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 0 #endif //////////////////////////////////////////////////////////////////////////////// @@ -517,14 +546,6 @@ BOOST_PP_REPEAT_FROM_TO( // Some utilities for implementing allocator_traits, but useful elsewhere so // they're always defined. -#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) -#include -#endif - -namespace boost { -namespace unordered { -namespace detail { - //////////////////////////////////////////////////////////////////////////// // Integral_constrant, true_type, false_type // @@ -1167,6 +1188,10 @@ struct rebind_wrap : boost::container::allocator_traits< #endif +//////////////////////////////////////////////////////////////////////////// +// Functions used to construct nodes. Emulates variadic construction, +// piecewise construction etc. + namespace boost { namespace unordered { namespace detail { @@ -1688,19 +1713,6 @@ construct_node_pair(Alloc& alloc, BOOST_FWD_REF(Key) k, BOOST_FWD_REF(Mapped) m) #pragma warning(pop) #endif -namespace boost { -namespace unordered { -namespace detail { - -template struct table; -template struct bucket; -struct ptr_bucket; -template struct table_impl; -template struct grouped_table_impl; -} -} -} - // The 'iterator_detail' namespace was a misguided attempt at avoiding ADL // in the detail namespace. It didn't work because the template parameters // were in detail. I'm not changing it at the moment to be safe. I might @@ -1714,15 +1726,6 @@ namespace iterator_detail { // // all no throw -template struct iterator; -template struct c_iterator; -template struct l_iterator; -template struct cl_iterator; - -// Local Iterators -// -// all no throw - template struct l_iterator : public std::iterator::type #endif -} -} -} #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable : 4127) // conditional expression is constant #endif -namespace boost { -namespace unordered { -namespace detail { - //////////////////////////////////////////////////////////////////////////// // convert double to std::size_t @@ -3122,18 +3118,12 @@ inline void table::reserve(std::size_t num_elements) rehash(static_cast( std::ceil(static_cast(num_elements) / mlf_))); } -} -} -} #if defined(BOOST_MSVC) #pragma warning(pop) #endif -namespace boost { -namespace unordered { -namespace detail { - +//////////////////////////////////////////////////////////////////////// // key extractors // // no throw @@ -3276,17 +3266,9 @@ template struct map_extractor BOOST_UNORDERED_KEY_FROM_TUPLE(std::) #endif }; -} -} -} -namespace boost { -namespace unordered { -namespace detail { - -template struct unique_node; -template struct ptr_node; -template struct table_impl; +//////////////////////////////////////////////////////////////////////// +// Unique nodes template struct unique_node : boost::unordered::detail::value_base @@ -3913,17 +3895,9 @@ struct table_impl : boost::unordered::detail::table } } }; -} -} -} -namespace boost { -namespace unordered { -namespace detail { - -template struct grouped_node; -template struct grouped_ptr_node; -template struct grouped_table_impl; +//////////////////////////////////////////////////////////////////////// +// Grouped nodes template struct grouped_node : boost::unordered::detail::value_base