From 21a24d6cd7d3e80f559186db795a838db696f13e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 27 Feb 2017 03:59:02 +0000 Subject: [PATCH] Support node_handle --- doc/ref.php | 261 +++++++ doc/ref.xml | 640 +++++++++++++++++- .../boost/unordered/detail/implementation.hpp | 265 +++++++- include/boost/unordered/detail/map.hpp | 23 + include/boost/unordered/detail/set.hpp | 22 + include/boost/unordered/unordered_map.hpp | 264 +++++++- include/boost/unordered/unordered_map_fwd.hpp | 3 + include/boost/unordered/unordered_set.hpp | 261 +++++++ include/boost/unordered/unordered_set_fwd.hpp | 3 + test/Jamfile.v2 | 6 + test/helpers/equivalent.hpp | 1 + test/unordered/compile_map.cpp | 15 +- test/unordered/compile_set.cpp | 15 +- test/unordered/compile_tests.hpp | 84 ++- test/unordered/extract_tests.cpp | 140 ++++ test/unordered/insert_node_type_fail.cpp | 29 + test/unordered/node_handle_tests.cpp | 436 ++++++++++++ 17 files changed, 2419 insertions(+), 49 deletions(-) create mode 100644 test/unordered/extract_tests.cpp create mode 100644 test/unordered/insert_node_type_fail.cpp create mode 100644 test/unordered/node_handle_tests.cpp diff --git a/doc/ref.php b/doc/ref.php index 3847ede3..f6e26e91 100644 --- a/doc/ref.php +++ b/doc/ref.php @@ -189,6 +189,20 @@ EOL; A const_local_iterator object can be used to iterate through a single bucket. + + implementation-defined + + See node_handle_ for details. + + + + + implementation-defined + + Structure returned by inserting node_type. + + + size() == 0 @@ -876,6 +890,142 @@ EOL; Pointers and references to elements are never invalidated. + + + initializer_list<value_type> + + void + + Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent . + + + value_type is EmplaceConstructible into + X from *first. + + + When inserting a single element, if an exception is thrown by an operation other than a call to hasher the function has no effect. + + + Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + Pointers and references to elements are never invalidated. + + + + + const_iterator + + node_type + + Removes the element pointed to by position. + + + A node_type owning the element. + + + + + key_type const& + + node_type + + Removes an element with key equivalent to k. + + + A node_type owning the element if found, otherwise an empty node_type. + + + Only throws an exception if it is thrown by hasher or key_equal. + + + + + node_type&& + + + + If nh is empty, has no affect. + + Otherwise inserts the element owned by nh + + Otherwise inserts the element owned by nh + if and only if there is no element in the container with an equivalent . + + + + + nh is empty or nh.get_allocator() is equal to the container's allocator. + + + + If nh was empty, returns end(). + Otherwise returns an iterator pointing to the newly inserted element. + + If nh was empty, returns an insert_return_type with: + inserted equal to false, + position equal to end() and + node empty. + Otherwise if there was already an element with an equivalent key, returns an insert_return_type with: + inserted equal to false, + position pointing to a matching element and + node contains the node from nh. + Otherwise if the insertion succeeded, returns an insert_return_type with: + inserted equal to true, + position pointing to the newly inserted element and + node empty. + + + + If an exception is thrown by an operation other than a call to hasher the function has no effect. + + + Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + Pointers and references to elements are never invalidated. + + + + + const_iterator + + + node_type&& + + iterator + + If nh is empty, has no affect. + + Otherwise inserts the element owned by nh + + Otherwise inserts the element owned by nh + if and only if there is no element in the container with an equivalent . + + If there is already an element in the container with an equivalent + has no effect on nh (i.e. nh still contains the node.) + + hint is a suggestion to where the element should be inserted. + + + nh is empty or nh.get_allocator() is equal to the container's allocator. + + + + If nh was empty, returns end(). + Otherwise returns an iterator pointing to the newly inserted element. + + If nh was empty returns end(). + If there was already an element in the container with an equivalent + returns an iterator pointing to that. + Otherwise returns an iterator pointing to the newly inserted element. + + + + If an exception is thrown by an operation other than a call to hasher the function has no effect. + + + The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same . + Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + Pointers and references to elements are never invalidated. + + const_iterator @@ -1416,6 +1566,115 @@ EOL; + + + + + + An object that owns a single element extracted from an + unordered_ or an + unordered_multi, that + can then be inserted into a compatible container type. + + + + The name and template parameters of this type is implementation + defined, and should be obtained using the node_type + member typedef from the appropriate container. + + + + + + typename Container::key_type + + + typename Container::mapped_type + + + + typename Container::value_type> + + + + typename Container::allocator_type> + + + + + + + && + + + + + && + + & + + + + key_type& + + + mapped_type& + + + + value_type& + + + + allocator_type + + + + + bool + + + + & + + void + + + In C++17 is also noexcept if ator_traits::is_always_equal::value is true. + But we don't support that trait yet. + + + + + + + + & + + + & + + void + + x.swap(y) + + + + + +