From af94e6a40eb96eb88259cc5fa0e832fc720af532 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 01/16] Reorder the constructors to match the draft standard In order to make it easier to check against the standard. This includes collapsing some of the input iterator overloads into one constructor. --- include/boost/unordered/unordered_map.hpp | 376 ++++++++++------------ include/boost/unordered/unordered_set.hpp | 375 ++++++++++----------- 2 files changed, 351 insertions(+), 400 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 75e8a02a..8da55311 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -85,36 +85,14 @@ template class unordered_map const key_equal& = key_equal(), const allocator_type& = allocator_type()); - explicit unordered_map(size_type, const allocator_type&); - - explicit unordered_map(size_type, const hasher&, const allocator_type&); - - explicit unordered_map(allocator_type const&); - - template unordered_map(InputIt, InputIt); - template - unordered_map(InputIt, InputIt, size_type, const hasher& = hasher(), - const key_equal& = key_equal()); - - template - unordered_map(InputIt, InputIt, size_type, const hasher&, const key_equal&, - const allocator_type&); - - template - unordered_map( - InputIt, InputIt, size_type, const hasher&, const allocator_type&); - - template - unordered_map(InputIt, InputIt, size_type, const allocator_type&); - - // copy/move constructors + unordered_map(InputIt, InputIt, + size_type = boost::unordered::detail::default_bucket_count, + const hasher& = hasher(), const key_equal& = key_equal(), + const allocator_type& = allocator_type()); unordered_map(unordered_map const&); - unordered_map(unordered_map const&, allocator_type const&); - unordered_map(BOOST_RV_REF(unordered_map), allocator_type const&); - #if defined(BOOST_UNORDERED_USE_MOVE) unordered_map(BOOST_RV_REF(unordered_map) other) BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) @@ -129,15 +107,36 @@ template class unordered_map } #endif + explicit unordered_map(allocator_type const&); + + unordered_map(unordered_map const&, allocator_type const&); + + unordered_map(BOOST_RV_REF(unordered_map), allocator_type const&); + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_map(std::initializer_list, size_type = boost::unordered::detail::default_bucket_count, const hasher& = hasher(), const key_equal& l = key_equal(), const allocator_type& = allocator_type()); - unordered_map(std::initializer_list, size_type, const hasher&, - const allocator_type&); +#endif + + explicit unordered_map(size_type, const allocator_type&); + + explicit unordered_map(size_type, const hasher&, const allocator_type&); + + template + unordered_map(InputIt, InputIt, size_type, const allocator_type&); + + template + unordered_map( + InputIt, InputIt, size_type, const hasher&, const allocator_type&); + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_map( std::initializer_list, size_type, const allocator_type&); + + unordered_map(std::initializer_list, size_type, const hasher&, + const allocator_type&); #endif // Destructor @@ -800,37 +799,14 @@ template class unordered_multimap const key_equal& = key_equal(), const allocator_type& = allocator_type()); - explicit unordered_multimap(size_type, const allocator_type&); - - explicit unordered_multimap( - size_type, const hasher&, const allocator_type&); - - explicit unordered_multimap(allocator_type const&); - - template unordered_multimap(InputIt, InputIt); - template - unordered_multimap(InputIt, InputIt, size_type, const hasher& = hasher(), - const key_equal& = key_equal()); - - template - unordered_multimap(InputIt, InputIt, size_type, const hasher&, - const key_equal&, const allocator_type&); - - template - unordered_multimap( - InputIt, InputIt, size_type, const hasher&, const allocator_type&); - - template - unordered_multimap(InputIt, InputIt, size_type, const allocator_type&); - - // copy/move constructors + unordered_multimap(InputIt, InputIt, + size_type = boost::unordered::detail::default_bucket_count, + const hasher& = hasher(), const key_equal& = key_equal(), + const allocator_type& = allocator_type()); unordered_multimap(unordered_multimap const&); - unordered_multimap(unordered_multimap const&, allocator_type const&); - unordered_multimap(BOOST_RV_REF(unordered_multimap), allocator_type const&); - #if defined(BOOST_UNORDERED_USE_MOVE) unordered_multimap(BOOST_RV_REF(unordered_multimap) other) BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) @@ -845,15 +821,37 @@ template class unordered_multimap } #endif + explicit unordered_multimap(allocator_type const&); + + unordered_multimap(unordered_multimap const&, allocator_type const&); + + unordered_multimap(BOOST_RV_REF(unordered_multimap), allocator_type const&); + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_multimap(std::initializer_list, size_type = boost::unordered::detail::default_bucket_count, const hasher& = hasher(), const key_equal& l = key_equal(), const allocator_type& = allocator_type()); - unordered_multimap(std::initializer_list, size_type, - const hasher&, const allocator_type&); +#endif + + explicit unordered_multimap(size_type, const allocator_type&); + + explicit unordered_multimap( + size_type, const hasher&, const allocator_type&); + + template + unordered_multimap(InputIt, InputIt, size_type, const allocator_type&); + + template + unordered_multimap( + InputIt, InputIt, size_type, const hasher&, const allocator_type&); + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_multimap( std::initializer_list, size_type, const allocator_type&); + + unordered_multimap(std::initializer_list, size_type, + const hasher&, const allocator_type&); #endif // Destructor @@ -1243,16 +1241,17 @@ unordered_map::unordered_map(size_type n, const hasher& hf, } template -unordered_map::unordered_map( - size_type n, const allocator_type& a) - : table_(n, hasher(), key_equal(), a) +template +unordered_map::unordered_map(InputIt f, InputIt l, size_type n, + const hasher& hf, const key_equal& eql, const allocator_type& a) + : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) { + table_.insert_range(f, l); } template -unordered_map::unordered_map( - size_type n, const hasher& hf, const allocator_type& a) - : table_(n, hf, key_equal(), a) +unordered_map::unordered_map(unordered_map const& other) + : table_(other.table_) { } @@ -1270,65 +1269,6 @@ unordered_map::unordered_map( { } -template -template -unordered_map::unordered_map(InputIt f, InputIt l) - : table_(boost::unordered::detail::initial_size(f, l), hasher(), - key_equal(), allocator_type()) -{ - table_.insert_range(f, l); -} - -template -template -unordered_map::unordered_map( - InputIt f, InputIt l, size_type n, const hasher& hf, const key_equal& eql) - : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, - allocator_type()) -{ - table_.insert_range(f, l); -} - -template -template -unordered_map::unordered_map(InputIt f, InputIt l, size_type n, - const hasher& hf, const key_equal& eql, const allocator_type& a) - : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) -{ - table_.insert_range(f, l); -} - -template -template -unordered_map::unordered_map(InputIt f, InputIt l, size_type n, - const hasher& hf, const allocator_type& a) - : table_( - boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) -{ - table_.insert_range(f, l); -} - -template -template -unordered_map::unordered_map( - InputIt f, InputIt l, size_type n, const allocator_type& a) - : table_(boost::unordered::detail::initial_size(f, l, n), hasher(), - key_equal(), a) -{ - table_.insert_range(f, l); -} - -template -unordered_map::~unordered_map() BOOST_NOEXCEPT -{ -} - -template -unordered_map::unordered_map(unordered_map const& other) - : table_(other.table_) -{ -} - template unordered_map::unordered_map( BOOST_RV_REF(unordered_map) other, allocator_type const& a) @@ -1349,17 +1289,44 @@ unordered_map::unordered_map( table_.insert_range(list.begin(), list.end()); } +#endif + template unordered_map::unordered_map( - std::initializer_list list, size_type n, const hasher& hf, - const allocator_type& a) - : table_( - boost::unordered::detail::initial_size(list.begin(), list.end(), n), - hf, key_equal(), a) + size_type n, const allocator_type& a) + : table_(n, hasher(), key_equal(), a) { - table_.insert_range(list.begin(), list.end()); } +template +unordered_map::unordered_map( + size_type n, const hasher& hf, const allocator_type& a) + : table_(n, hf, key_equal(), a) +{ +} + +template +template +unordered_map::unordered_map( + InputIt f, InputIt l, size_type n, const allocator_type& a) + : table_(boost::unordered::detail::initial_size(f, l, n), hasher(), + key_equal(), a) +{ + table_.insert_range(f, l); +} + +template +template +unordered_map::unordered_map(InputIt f, InputIt l, size_type n, + const hasher& hf, const allocator_type& a) + : table_( + boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) +{ + table_.insert_range(f, l); +} + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template unordered_map::unordered_map( std::initializer_list list, size_type n, @@ -1371,6 +1338,26 @@ unordered_map::unordered_map( table_.insert_range(list.begin(), list.end()); } +template +unordered_map::unordered_map( + std::initializer_list list, size_type n, const hasher& hf, + const allocator_type& a) + : table_( + boost::unordered::detail::initial_size(list.begin(), list.end(), n), + hf, key_equal(), a) +{ + table_.insert_range(list.begin(), list.end()); +} + +#endif + +template +unordered_map::~unordered_map() BOOST_NOEXCEPT +{ +} + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template unordered_map& unordered_map::operator=( std::initializer_list list) @@ -1663,16 +1650,19 @@ unordered_multimap::unordered_multimap(size_type n, } template -unordered_multimap::unordered_multimap( - size_type n, const allocator_type& a) - : table_(n, hasher(), key_equal(), a) +template +unordered_multimap::unordered_multimap(InputIt f, InputIt l, + size_type n, const hasher& hf, const key_equal& eql, + const allocator_type& a) + : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) { + table_.insert_range(f, l); } template unordered_multimap::unordered_multimap( - size_type n, const hasher& hf, const allocator_type& a) - : table_(n, hf, key_equal(), a) + unordered_multimap const& other) + : table_(other.table_) { } @@ -1690,67 +1680,6 @@ unordered_multimap::unordered_multimap( { } -template -template -unordered_multimap::unordered_multimap(InputIt f, InputIt l) - : table_(boost::unordered::detail::initial_size(f, l), hasher(), - key_equal(), allocator_type()) -{ - table_.insert_range(f, l); -} - -template -template -unordered_multimap::unordered_multimap( - InputIt f, InputIt l, size_type n, const hasher& hf, const key_equal& eql) - : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, - allocator_type()) -{ - table_.insert_range(f, l); -} - -template -template -unordered_multimap::unordered_multimap(InputIt f, InputIt l, - size_type n, const hasher& hf, const key_equal& eql, - const allocator_type& a) - : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) -{ - table_.insert_range(f, l); -} - -template -template -unordered_multimap::unordered_multimap(InputIt f, InputIt l, - size_type n, const hasher& hf, const allocator_type& a) - : table_( - boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) -{ - table_.insert_range(f, l); -} - -template -template -unordered_multimap::unordered_multimap( - InputIt f, InputIt l, size_type n, const allocator_type& a) - : table_(boost::unordered::detail::initial_size(f, l, n), hasher(), - key_equal(), a) -{ - table_.insert_range(f, l); -} - -template -unordered_multimap::~unordered_multimap() BOOST_NOEXCEPT -{ -} - -template -unordered_multimap::unordered_multimap( - unordered_multimap const& other) - : table_(other.table_) -{ -} - template unordered_multimap::unordered_multimap( BOOST_RV_REF(unordered_multimap) other, allocator_type const& a) @@ -1771,17 +1700,44 @@ unordered_multimap::unordered_multimap( table_.insert_range(list.begin(), list.end()); } +#endif + template unordered_multimap::unordered_multimap( - std::initializer_list list, size_type n, const hasher& hf, - const allocator_type& a) - : table_( - boost::unordered::detail::initial_size(list.begin(), list.end(), n), - hf, key_equal(), a) + size_type n, const allocator_type& a) + : table_(n, hasher(), key_equal(), a) { - table_.insert_range(list.begin(), list.end()); } +template +unordered_multimap::unordered_multimap( + size_type n, const hasher& hf, const allocator_type& a) + : table_(n, hf, key_equal(), a) +{ +} + +template +template +unordered_multimap::unordered_multimap( + InputIt f, InputIt l, size_type n, const allocator_type& a) + : table_(boost::unordered::detail::initial_size(f, l, n), hasher(), + key_equal(), a) +{ + table_.insert_range(f, l); +} + +template +template +unordered_multimap::unordered_multimap(InputIt f, InputIt l, + size_type n, const hasher& hf, const allocator_type& a) + : table_( + boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) +{ + table_.insert_range(f, l); +} + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template unordered_multimap::unordered_multimap( std::initializer_list list, size_type n, @@ -1793,6 +1749,26 @@ unordered_multimap::unordered_multimap( table_.insert_range(list.begin(), list.end()); } +template +unordered_multimap::unordered_multimap( + std::initializer_list list, size_type n, const hasher& hf, + const allocator_type& a) + : table_( + boost::unordered::detail::initial_size(list.begin(), list.end(), n), + hf, key_equal(), a) +{ + table_.insert_range(list.begin(), list.end()); +} + +#endif + +template +unordered_multimap::~unordered_multimap() BOOST_NOEXCEPT +{ +} + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template unordered_multimap& unordered_multimap::operator=( std::initializer_list list) diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index afb25916..52e357f1 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -83,36 +83,14 @@ template class unordered_set const key_equal& = key_equal(), const allocator_type& = allocator_type()); - explicit unordered_set(size_type, const allocator_type&); - - explicit unordered_set(size_type, const hasher&, const allocator_type&); - - explicit unordered_set(allocator_type const&); - - template unordered_set(InputIt, InputIt); - template - unordered_set(InputIt, InputIt, size_type, const hasher& = hasher(), - const key_equal& = key_equal()); - - template - unordered_set(InputIt, InputIt, size_type, const hasher&, const key_equal&, - const allocator_type&); - - template - unordered_set( - InputIt, InputIt, size_type, const hasher&, const allocator_type&); - - template - unordered_set(InputIt, InputIt, size_type, const allocator_type&); - - // copy/move constructors + unordered_set(InputIt, InputIt, + size_type = boost::unordered::detail::default_bucket_count, + const hasher& = hasher(), const key_equal& = key_equal(), + const allocator_type& = allocator_type()); unordered_set(unordered_set const&); - unordered_set(unordered_set const&, allocator_type const&); - unordered_set(BOOST_RV_REF(unordered_set), allocator_type const&); - #if defined(BOOST_UNORDERED_USE_MOVE) unordered_set(BOOST_RV_REF(unordered_set) other) BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) @@ -127,15 +105,36 @@ template class unordered_set } #endif + explicit unordered_set(allocator_type const&); + + unordered_set(unordered_set const&, allocator_type const&); + + unordered_set(BOOST_RV_REF(unordered_set), allocator_type const&); + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_set(std::initializer_list, size_type = boost::unordered::detail::default_bucket_count, const hasher& = hasher(), const key_equal& l = key_equal(), const allocator_type& = allocator_type()); - unordered_set(std::initializer_list, size_type, const hasher&, - const allocator_type&); +#endif + + explicit unordered_set(size_type, const allocator_type&); + + explicit unordered_set(size_type, const hasher&, const allocator_type&); + + template + unordered_set(InputIt, InputIt, size_type, const allocator_type&); + + template + unordered_set( + InputIt, InputIt, size_type, const hasher&, const allocator_type&); + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_set( std::initializer_list, size_type, const allocator_type&); + + unordered_set(std::initializer_list, size_type, const hasher&, + const allocator_type&); #endif // Destructor @@ -541,37 +540,14 @@ template class unordered_multiset const key_equal& = key_equal(), const allocator_type& = allocator_type()); - explicit unordered_multiset(size_type, const allocator_type&); - - explicit unordered_multiset( - size_type, const hasher&, const allocator_type&); - - explicit unordered_multiset(allocator_type const&); - - template unordered_multiset(InputIt, InputIt); - template - unordered_multiset(InputIt, InputIt, size_type, const hasher& = hasher(), - const key_equal& = key_equal()); - - template - unordered_multiset(InputIt, InputIt, size_type, const hasher&, - const key_equal&, const allocator_type&); - - template - unordered_multiset( - InputIt, InputIt, size_type, const hasher&, const allocator_type&); - - template - unordered_multiset(InputIt, InputIt, size_type, const allocator_type&); - - // copy/move constructors + unordered_multiset(InputIt, InputIt, + size_type = boost::unordered::detail::default_bucket_count, + const hasher& = hasher(), const key_equal& = key_equal(), + const allocator_type& = allocator_type()); unordered_multiset(unordered_multiset const&); - unordered_multiset(unordered_multiset const&, allocator_type const&); - unordered_multiset(BOOST_RV_REF(unordered_multiset), allocator_type const&); - #if defined(BOOST_UNORDERED_USE_MOVE) unordered_multiset(BOOST_RV_REF(unordered_multiset) other) BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) @@ -586,15 +562,37 @@ template class unordered_multiset } #endif + explicit unordered_multiset(allocator_type const&); + + unordered_multiset(unordered_multiset const&, allocator_type const&); + + unordered_multiset(BOOST_RV_REF(unordered_multiset), allocator_type const&); + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_multiset(std::initializer_list, size_type = boost::unordered::detail::default_bucket_count, const hasher& = hasher(), const key_equal& l = key_equal(), const allocator_type& = allocator_type()); - unordered_multiset(std::initializer_list, size_type, - const hasher&, const allocator_type&); +#endif + + explicit unordered_multiset(size_type, const allocator_type&); + + explicit unordered_multiset( + size_type, const hasher&, const allocator_type&); + + template + unordered_multiset(InputIt, InputIt, size_type, const allocator_type&); + + template + unordered_multiset( + InputIt, InputIt, size_type, const hasher&, const allocator_type&); + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_multiset( std::initializer_list, size_type, const allocator_type&); + + unordered_multiset(std::initializer_list, size_type, + const hasher&, const allocator_type&); #endif // Destructor @@ -943,7 +941,6 @@ template class unordered_multiset }; // class template unordered_multiset //////////////////////////////////////////////////////////////////////////////// - template unordered_set::unordered_set() : table_(boost::unordered::detail::default_bucket_count, hasher(), @@ -959,15 +956,17 @@ unordered_set::unordered_set(size_type n, const hasher& hf, } template -unordered_set::unordered_set(size_type n, const allocator_type& a) - : table_(n, hasher(), key_equal(), a) +template +unordered_set::unordered_set(InputIt f, InputIt l, size_type n, + const hasher& hf, const key_equal& eql, const allocator_type& a) + : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) { + table_.insert_range(f, l); } template -unordered_set::unordered_set( - size_type n, const hasher& hf, const allocator_type& a) - : table_(n, hf, key_equal(), a) +unordered_set::unordered_set(unordered_set const& other) + : table_(other.table_) { } @@ -985,65 +984,6 @@ unordered_set::unordered_set( { } -template -template -unordered_set::unordered_set(InputIt f, InputIt l) - : table_(boost::unordered::detail::initial_size(f, l), hasher(), - key_equal(), allocator_type()) -{ - table_.insert_range(f, l); -} - -template -template -unordered_set::unordered_set( - InputIt f, InputIt l, size_type n, const hasher& hf, const key_equal& eql) - : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, - allocator_type()) -{ - table_.insert_range(f, l); -} - -template -template -unordered_set::unordered_set(InputIt f, InputIt l, size_type n, - const hasher& hf, const key_equal& eql, const allocator_type& a) - : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) -{ - table_.insert_range(f, l); -} - -template -template -unordered_set::unordered_set(InputIt f, InputIt l, size_type n, - const hasher& hf, const allocator_type& a) - : table_( - boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) -{ - table_.insert_range(f, l); -} - -template -template -unordered_set::unordered_set( - InputIt f, InputIt l, size_type n, const allocator_type& a) - : table_(boost::unordered::detail::initial_size(f, l, n), hasher(), - key_equal(), a) -{ - table_.insert_range(f, l); -} - -template -unordered_set::~unordered_set() BOOST_NOEXCEPT -{ -} - -template -unordered_set::unordered_set(unordered_set const& other) - : table_(other.table_) -{ -} - template unordered_set::unordered_set( BOOST_RV_REF(unordered_set) other, allocator_type const& a) @@ -1064,16 +1004,43 @@ unordered_set::unordered_set(std::initializer_list list, table_.insert_range(list.begin(), list.end()); } +#endif + template -unordered_set::unordered_set(std::initializer_list list, - size_type n, const hasher& hf, const allocator_type& a) - : table_( - boost::unordered::detail::initial_size(list.begin(), list.end(), n), - hf, key_equal(), a) +unordered_set::unordered_set(size_type n, const allocator_type& a) + : table_(n, hasher(), key_equal(), a) { - table_.insert_range(list.begin(), list.end()); } +template +unordered_set::unordered_set( + size_type n, const hasher& hf, const allocator_type& a) + : table_(n, hf, key_equal(), a) +{ +} + +template +template +unordered_set::unordered_set( + InputIt f, InputIt l, size_type n, const allocator_type& a) + : table_(boost::unordered::detail::initial_size(f, l, n), hasher(), + key_equal(), a) +{ + table_.insert_range(f, l); +} + +template +template +unordered_set::unordered_set(InputIt f, InputIt l, size_type n, + const hasher& hf, const allocator_type& a) + : table_( + boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) +{ + table_.insert_range(f, l); +} + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template unordered_set::unordered_set(std::initializer_list list, size_type n, const allocator_type& a) @@ -1084,6 +1051,25 @@ unordered_set::unordered_set(std::initializer_list list, table_.insert_range(list.begin(), list.end()); } +template +unordered_set::unordered_set(std::initializer_list list, + size_type n, const hasher& hf, const allocator_type& a) + : table_( + boost::unordered::detail::initial_size(list.begin(), list.end(), n), + hf, key_equal(), a) +{ + table_.insert_range(list.begin(), list.end()); +} + +#endif + +template +unordered_set::~unordered_set() BOOST_NOEXCEPT +{ +} + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template unordered_set& unordered_set::operator=( std::initializer_list list) @@ -1329,16 +1315,19 @@ unordered_multiset::unordered_multiset(size_type n, } template -unordered_multiset::unordered_multiset( - size_type n, const allocator_type& a) - : table_(n, hasher(), key_equal(), a) +template +unordered_multiset::unordered_multiset(InputIt f, InputIt l, + size_type n, const hasher& hf, const key_equal& eql, + const allocator_type& a) + : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) { + table_.insert_range(f, l); } template unordered_multiset::unordered_multiset( - size_type n, const hasher& hf, const allocator_type& a) - : table_(n, hf, key_equal(), a) + unordered_multiset const& other) + : table_(other.table_) { } @@ -1356,67 +1345,6 @@ unordered_multiset::unordered_multiset( { } -template -template -unordered_multiset::unordered_multiset(InputIt f, InputIt l) - : table_(boost::unordered::detail::initial_size(f, l), hasher(), - key_equal(), allocator_type()) -{ - table_.insert_range(f, l); -} - -template -template -unordered_multiset::unordered_multiset( - InputIt f, InputIt l, size_type n, const hasher& hf, const key_equal& eql) - : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, - allocator_type()) -{ - table_.insert_range(f, l); -} - -template -template -unordered_multiset::unordered_multiset(InputIt f, InputIt l, - size_type n, const hasher& hf, const key_equal& eql, - const allocator_type& a) - : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) -{ - table_.insert_range(f, l); -} - -template -template -unordered_multiset::unordered_multiset(InputIt f, InputIt l, - size_type n, const hasher& hf, const allocator_type& a) - : table_( - boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) -{ - table_.insert_range(f, l); -} - -template -template -unordered_multiset::unordered_multiset( - InputIt f, InputIt l, size_type n, const allocator_type& a) - : table_(boost::unordered::detail::initial_size(f, l, n), hasher(), - key_equal(), a) -{ - table_.insert_range(f, l); -} - -template -unordered_multiset::~unordered_multiset() BOOST_NOEXCEPT -{ -} - -template -unordered_multiset::unordered_multiset( - unordered_multiset const& other) - : table_(other.table_) -{ -} - template unordered_multiset::unordered_multiset( BOOST_RV_REF(unordered_multiset) other, allocator_type const& a) @@ -1437,17 +1365,44 @@ unordered_multiset::unordered_multiset( table_.insert_range(list.begin(), list.end()); } +#endif + template unordered_multiset::unordered_multiset( - std::initializer_list list, size_type n, const hasher& hf, - const allocator_type& a) - : table_( - boost::unordered::detail::initial_size(list.begin(), list.end(), n), - hf, key_equal(), a) + size_type n, const allocator_type& a) + : table_(n, hasher(), key_equal(), a) { - table_.insert_range(list.begin(), list.end()); } +template +unordered_multiset::unordered_multiset( + size_type n, const hasher& hf, const allocator_type& a) + : table_(n, hf, key_equal(), a) +{ +} + +template +template +unordered_multiset::unordered_multiset( + InputIt f, InputIt l, size_type n, const allocator_type& a) + : table_(boost::unordered::detail::initial_size(f, l, n), hasher(), + key_equal(), a) +{ + table_.insert_range(f, l); +} + +template +template +unordered_multiset::unordered_multiset(InputIt f, InputIt l, + size_type n, const hasher& hf, const allocator_type& a) + : table_( + boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) +{ + table_.insert_range(f, l); +} + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template unordered_multiset::unordered_multiset( std::initializer_list list, size_type n, @@ -1459,6 +1414,26 @@ unordered_multiset::unordered_multiset( table_.insert_range(list.begin(), list.end()); } +template +unordered_multiset::unordered_multiset( + std::initializer_list list, size_type n, const hasher& hf, + const allocator_type& a) + : table_( + boost::unordered::detail::initial_size(list.begin(), list.end(), n), + hf, key_equal(), a) +{ + table_.insert_range(list.begin(), list.end()); +} + +#endif + +template +unordered_multiset::~unordered_multiset() BOOST_NOEXCEPT +{ +} + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template unordered_multiset& unordered_multiset::operator=( std::initializer_list list) From e4a00980f8bd83c8fb3ac1d587f3b20821a95d43 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 02/16] Commented out noexcept for move assignment --- include/boost/unordered/unordered_map.hpp | 16 ++++++++++++++++ include/boost/unordered/unordered_set.hpp | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 8da55311..8b5fffe2 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -153,6 +153,10 @@ template class unordered_map } unordered_map& operator=(BOOST_RV_REF(unordered_map) x) + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) { table_.move_assign(x.table_); return *this; @@ -166,6 +170,10 @@ template class unordered_map #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_map& operator=(unordered_map&& x) + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) { table_.move_assign(x.table_); return *this; @@ -868,6 +876,10 @@ template class unordered_multimap } unordered_multimap& operator=(BOOST_RV_REF(unordered_multimap) x) + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) { table_.move_assign(x.table_); return *this; @@ -881,6 +893,10 @@ template class unordered_multimap #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_multimap& operator=(unordered_multimap&& x) + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) { table_.move_assign(x.table_); return *this; diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 52e357f1..52136bc6 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -151,6 +151,10 @@ template class unordered_set } unordered_set& operator=(BOOST_RV_REF(unordered_set) x) + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) { table_.move_assign(x.table_); return *this; @@ -164,6 +168,10 @@ template class unordered_set #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_set& operator=(unordered_set&& x) + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) { table_.move_assign(x.table_); return *this; @@ -609,6 +617,10 @@ template class unordered_multiset } unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x) + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) { table_.move_assign(x.table_); return *this; @@ -622,6 +634,10 @@ template class unordered_multiset #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_multiset& operator=(unordered_multiset&& x) + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) { table_.move_assign(x.table_); return *this; From 1a18cd2196d8d0bcb2433cdabdef03168bd5a7af Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 03/16] Move capacity functions to match order in standard --- include/boost/unordered/unordered_map.hpp | 32 +++++++++++------------ include/boost/unordered/unordered_set.hpp | 32 +++++++++++------------ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 8b5fffe2..41419b9d 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -190,14 +190,6 @@ template class unordered_map return table_.node_alloc(); } - // size and capacity - - bool empty() const BOOST_NOEXCEPT { return table_.size_ == 0; } - - size_type size() const BOOST_NOEXCEPT { return table_.size_; } - - size_type max_size() const BOOST_NOEXCEPT; - // iterators iterator begin() BOOST_NOEXCEPT { return iterator(table_.begin()); } @@ -218,6 +210,14 @@ template class unordered_map const_iterator cend() const BOOST_NOEXCEPT { return const_iterator(); } + // size and capacity + + bool empty() const BOOST_NOEXCEPT { return table_.size_ == 0; } + + size_type size() const BOOST_NOEXCEPT { return table_.size_; } + + size_type max_size() const BOOST_NOEXCEPT; + // extract node_type extract(const_iterator position) @@ -913,14 +913,6 @@ template class unordered_multimap return table_.node_alloc(); } - // size and capacity - - bool empty() const BOOST_NOEXCEPT { return table_.size_ == 0; } - - size_type size() const BOOST_NOEXCEPT { return table_.size_; } - - size_type max_size() const BOOST_NOEXCEPT; - // iterators iterator begin() BOOST_NOEXCEPT { return iterator(table_.begin()); } @@ -941,6 +933,14 @@ template class unordered_multimap const_iterator cend() const BOOST_NOEXCEPT { return const_iterator(); } + // size and capacity + + bool empty() const BOOST_NOEXCEPT { return table_.size_ == 0; } + + size_type size() const BOOST_NOEXCEPT { return table_.size_; } + + size_type max_size() const BOOST_NOEXCEPT; + // extract node_type extract(const_iterator position) diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 52136bc6..0bc240c1 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -188,14 +188,6 @@ template class unordered_set return table_.node_alloc(); } - // size and capacity - - bool empty() const BOOST_NOEXCEPT { return table_.size_ == 0; } - - size_type size() const BOOST_NOEXCEPT { return table_.size_; } - - size_type max_size() const BOOST_NOEXCEPT; - // iterators iterator begin() BOOST_NOEXCEPT { return iterator(table_.begin()); } @@ -216,6 +208,14 @@ template class unordered_set const_iterator cend() const BOOST_NOEXCEPT { return const_iterator(); } + // size and capacity + + bool empty() const BOOST_NOEXCEPT { return table_.size_ == 0; } + + size_type size() const BOOST_NOEXCEPT { return table_.size_; } + + size_type max_size() const BOOST_NOEXCEPT; + // extract node_type extract(const_iterator position) @@ -654,14 +654,6 @@ template class unordered_multiset return table_.node_alloc(); } - // size and capacity - - bool empty() const BOOST_NOEXCEPT { return table_.size_ == 0; } - - size_type size() const BOOST_NOEXCEPT { return table_.size_; } - - size_type max_size() const BOOST_NOEXCEPT; - // iterators iterator begin() BOOST_NOEXCEPT { return iterator(table_.begin()); } @@ -682,6 +674,14 @@ template class unordered_multiset const_iterator cend() const BOOST_NOEXCEPT { return const_iterator(); } + // size and capacity + + bool empty() const BOOST_NOEXCEPT { return table_.size_ == 0; } + + size_type size() const BOOST_NOEXCEPT { return table_.size_; } + + size_type max_size() const BOOST_NOEXCEPT; + // extract node_type extract(const_iterator position) From ab76814aa6af00c69877f442c7514179619abac5 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 04/16] Move 'insert_or_assign' into same order as draft standard --- include/boost/unordered/unordered_map.hpp | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 41419b9d..985e9142 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -581,6 +581,33 @@ template class unordered_map return this->emplace_hint(hint, boost::forward(obj)); } + template void insert(InputIt, InputIt); + +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + void insert(std::initializer_list); +#endif + + insert_return_type insert(BOOST_RV_REF(node_type) np) + { + insert_return_type result; + table_.move_insert_node_type(np, result); + return boost::move(result); + } + + iterator insert(const_iterator hint, BOOST_RV_REF(node_type) np) + { + return table_.move_insert_node_type_with_hint(hint, np); + } + +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + private: + // Note: Use r-value node_type to insert. + insert_return_type insert(node_type&); + iterator insert(const_iterator, node_type& np); + + public: +#endif + template std::pair insert_or_assign( key_type const& k, BOOST_FWD_REF(M) obj) @@ -612,33 +639,6 @@ template class unordered_map .first; } - template void insert(InputIt, InputIt); - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - void insert(std::initializer_list); -#endif - - insert_return_type insert(BOOST_RV_REF(node_type) np) - { - insert_return_type result; - table_.move_insert_node_type(np, result); - return boost::move(result); - } - - iterator insert(const_iterator hint, BOOST_RV_REF(node_type) np) - { - return table_.move_insert_node_type_with_hint(hint, np); - } - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - private: - // Note: Use r-value node_type to insert. - insert_return_type insert(node_type&); - iterator insert(const_iterator, node_type& np); - - public: -#endif - iterator erase(const_iterator); size_type erase(const key_type&); iterator erase(const_iterator, const_iterator); From d8969c71fca55a1a6b91ba812206e1ea99f7ecba Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 05/16] Move 'try_emplace' into same order as draft standard --- include/boost/unordered/unordered_map.hpp | 404 +++++++++++----------- 1 file changed, 209 insertions(+), 195 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 985e9142..7233aa27 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -246,36 +246,6 @@ template class unordered_map return table_.emplace_hint(hint, boost::forward(args)...); } - template - std::pair try_emplace( - key_type const& k, BOOST_FWD_REF(Args)... args) - { - return table_.try_emplace_impl(k, boost::forward(args)...); - } - - template - iterator try_emplace( - const_iterator hint, key_type const& k, BOOST_FWD_REF(Args)... args) - { - return table_.try_emplace_hint_impl( - hint, k, boost::forward(args)...); - } - - template - std::pair try_emplace( - BOOST_RV_REF(key_type) k, BOOST_FWD_REF(Args)... args) - { - return table_.try_emplace_impl( - boost::move(k), boost::forward(args)...); - } - - template - iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, - BOOST_FWD_REF(Args)... args) - { - return table_.try_emplace_hint_impl( - hint, boost::move(k), boost::forward(args)...); - } #else #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) @@ -302,18 +272,6 @@ template class unordered_map #endif - template - std::pair try_emplace(BOOST_FWD_REF(Key) k) - { - return table_.try_emplace_impl(boost::forward(k)); - } - - template - iterator try_emplace(const_iterator hint, BOOST_FWD_REF(Key) k) - { - return table_.try_emplace_hint_impl(hint, boost::forward(k)); - } - template std::pair emplace(BOOST_FWD_REF(A0) a0) { @@ -329,42 +287,6 @@ template class unordered_map boost::forward(a0))); } - template - std::pair try_emplace( - key_type const& k, BOOST_FWD_REF(A0) a0) - { - return table_.try_emplace_impl( - k, boost::unordered::detail::create_emplace_args( - boost::forward(a0))); - } - - template - iterator try_emplace( - const_iterator hint, key_type const& k, BOOST_FWD_REF(A0) a0) - { - return table_.try_emplace_hint_impl( - hint, k, boost::unordered::detail::create_emplace_args( - boost::forward(a0))); - } - - template - std::pair try_emplace( - BOOST_RV_REF(key_type) k, BOOST_FWD_REF(A0) a0) - { - return table_.try_emplace_impl( - boost::move(k), boost::unordered::detail::create_emplace_args( - boost::forward(a0))); - } - - template - iterator try_emplace( - const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(A0) a0) - { - return table_.try_emplace_hint_impl( - hint, boost::move(k), boost::unordered::detail::create_emplace_args( - boost::forward(a0))); - } - template std::pair emplace( BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) @@ -382,44 +304,6 @@ template class unordered_map boost::forward(a0), boost::forward(a1))); } - template - std::pair try_emplace( - key_type const& k, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) - { - return table_.try_emplace_impl( - k, boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1))); - } - - template - iterator try_emplace(const_iterator hint, key_type const& k, - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) - { - return table_.try_emplace_hint_impl( - hint, k, boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1))); - } - - template - std::pair try_emplace( - BOOST_RV_REF(key_type) k, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) - { - return table_.try_emplace_impl( - boost::move(k), - boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1))); - } - - template - iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) - { - return table_.try_emplace_hint_impl( - hint, boost::move(k), - boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1))); - } - template std::pair emplace( BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) @@ -439,49 +323,6 @@ template class unordered_map boost::forward(a2))); } - template - std::pair try_emplace(key_type const& k, - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) - { - return table_.try_emplace_impl( - k, boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))); - } - - template - iterator try_emplace(const_iterator hint, key_type const& k, - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) - { - return table_ - .try_emplace_impl_( - hint, k, boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))) - .first; - } - - template - std::pair try_emplace(BOOST_RV_REF(key_type) k, - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) - { - return table_.try_emplace_impl( - boost::move(k), boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))); - } - - template - iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) - { - return table_.try_emplace_hint_impl( - hint, boost::move(k), - boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))); - } - #define BOOST_UNORDERED_EMPLACE(z, n, _) \ template \ std::pair emplace( \ @@ -498,42 +339,6 @@ template class unordered_map return table_.emplace_hint( \ hint, boost::unordered::detail::create_emplace_args( \ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \ - } \ - \ - template \ - std::pair try_emplace( \ - key_type const& k, BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ - { \ - return table_.try_emplace_impl( \ - k, boost::unordered::detail::create_emplace_args( \ - BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \ - } \ - \ - template \ - iterator try_emplace(const_iterator hint, key_type const& k, \ - BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ - { \ - return table_.try_emplace_hint_impl(hint, k, \ - boost::unordered::detail::create_emplace_args(BOOST_PP_ENUM_##z( \ - n, BOOST_UNORDERED_CALL_FORWARD, a))); \ - } \ - \ - template \ - std::pair try_emplace(BOOST_RV_REF(key_type) k, \ - BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ - { \ - return table_.try_emplace_impl(boost::move(k), \ - boost::unordered::detail::create_emplace_args(BOOST_PP_ENUM_##z( \ - n, BOOST_UNORDERED_CALL_FORWARD, a))); \ - } \ - \ - template \ - iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, \ - BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ - { \ - return table_.try_emplace_hint_impl(hint, boost::move(k), \ - boost::unordered::detail::create_emplace_args(BOOST_PP_ENUM_##z( \ - n, BOOST_UNORDERED_CALL_FORWARD, a))); \ } BOOST_PP_REPEAT_FROM_TO( @@ -606,6 +411,215 @@ template class unordered_map iterator insert(const_iterator, node_type& np); public: +#endif + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + template + std::pair try_emplace( + key_type const& k, BOOST_FWD_REF(Args)... args) + { + return table_.try_emplace_impl(k, boost::forward(args)...); + } + + template + iterator try_emplace( + const_iterator hint, key_type const& k, BOOST_FWD_REF(Args)... args) + { + return table_.try_emplace_hint_impl( + hint, k, boost::forward(args)...); + } + + template + std::pair try_emplace( + BOOST_RV_REF(key_type) k, BOOST_FWD_REF(Args)... args) + { + return table_.try_emplace_impl( + boost::move(k), boost::forward(args)...); + } + + template + iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, + BOOST_FWD_REF(Args)... args) + { + return table_.try_emplace_hint_impl( + hint, boost::move(k), boost::forward(args)...); + } + +#else + + template + std::pair try_emplace(BOOST_FWD_REF(Key) k) + { + return table_.try_emplace_impl(boost::forward(k)); + } + + template + iterator try_emplace(const_iterator hint, BOOST_FWD_REF(Key) k) + { + return table_.try_emplace_hint_impl(hint, boost::forward(k)); + } + + template + std::pair try_emplace( + key_type const& k, BOOST_FWD_REF(A0) a0) + { + return table_.try_emplace_impl( + k, boost::unordered::detail::create_emplace_args( + boost::forward(a0))); + } + + template + iterator try_emplace( + const_iterator hint, key_type const& k, BOOST_FWD_REF(A0) a0) + { + return table_.try_emplace_hint_impl( + hint, k, boost::unordered::detail::create_emplace_args( + boost::forward(a0))); + } + + template + std::pair try_emplace( + BOOST_RV_REF(key_type) k, BOOST_FWD_REF(A0) a0) + { + return table_.try_emplace_impl( + boost::move(k), boost::unordered::detail::create_emplace_args( + boost::forward(a0))); + } + + template + iterator try_emplace( + const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(A0) a0) + { + return table_.try_emplace_hint_impl( + hint, boost::move(k), boost::unordered::detail::create_emplace_args( + boost::forward(a0))); + } + + template + std::pair try_emplace( + key_type const& k, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) + { + return table_.try_emplace_impl( + k, boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1))); + } + + template + iterator try_emplace(const_iterator hint, key_type const& k, + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) + { + return table_.try_emplace_hint_impl( + hint, k, boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1))); + } + + template + std::pair try_emplace( + BOOST_RV_REF(key_type) k, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) + { + return table_.try_emplace_impl( + boost::move(k), + boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1))); + } + + template + iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) + { + return table_.try_emplace_hint_impl( + hint, boost::move(k), + boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1))); + } + + template + std::pair try_emplace(key_type const& k, + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) + { + return table_.try_emplace_impl( + k, boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))); + } + + template + iterator try_emplace(const_iterator hint, key_type const& k, + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) + { + return table_ + .try_emplace_impl_( + hint, k, boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))) + .first; + } + + template + std::pair try_emplace(BOOST_RV_REF(key_type) k, + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) + { + return table_.try_emplace_impl( + boost::move(k), boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))); + } + + template + iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) + { + return table_.try_emplace_hint_impl( + hint, boost::move(k), + boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))); + } + +#define BOOST_UNORDERED_TRY_EMPLACE(z, n, _) \ + \ + template \ + std::pair try_emplace( \ + key_type const& k, BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ + { \ + return table_.try_emplace_impl( \ + k, boost::unordered::detail::create_emplace_args( \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \ + } \ + \ + template \ + iterator try_emplace(const_iterator hint, key_type const& k, \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ + { \ + return table_.try_emplace_hint_impl(hint, k, \ + boost::unordered::detail::create_emplace_args(BOOST_PP_ENUM_##z( \ + n, BOOST_UNORDERED_CALL_FORWARD, a))); \ + } \ + \ + template \ + std::pair try_emplace(BOOST_RV_REF(key_type) k, \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ + { \ + return table_.try_emplace_impl(boost::move(k), \ + boost::unordered::detail::create_emplace_args(BOOST_PP_ENUM_##z( \ + n, BOOST_UNORDERED_CALL_FORWARD, a))); \ + } \ + \ + template \ + iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ + { \ + return table_.try_emplace_hint_impl(hint, boost::move(k), \ + boost::unordered::detail::create_emplace_args(BOOST_PP_ENUM_##z( \ + n, BOOST_UNORDERED_CALL_FORWARD, a))); \ + } + + BOOST_PP_REPEAT_FROM_TO( + 4, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_TRY_EMPLACE, _) + +#undef BOOST_UNORDERED_TRY_EMPLACE + #endif template From e2e995938998a3c822a8b139c5d994f5c5333801 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 06/16] Split up emplace and emplace_hint code Busywork I guess, but I think it's more readable this way. The emplace macros are still unreadable, but I think they're rarely used. Btw. a bit weird that clang format has removed the indentation on the '// emplace' comment, not sure why that is. --- include/boost/unordered/unordered_map.hpp | 150 +++++++++++++--------- include/boost/unordered/unordered_set.hpp | 143 +++++++++++++-------- 2 files changed, 177 insertions(+), 116 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 7233aa27..0a257b7e 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -234,18 +234,13 @@ template class unordered_map // emplace #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template std::pair emplace(BOOST_FWD_REF(Args)... args) { return table_.emplace(boost::forward(args)...); } - template - iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) - { - return table_.emplace_hint(hint, boost::forward(args)...); - } - #else #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) @@ -262,6 +257,46 @@ template class unordered_map return this->emplace(boost::move(v)); } +#endif + + template + std::pair emplace(BOOST_FWD_REF(A0) a0) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0))); + } + + template + std::pair emplace( + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1))); + } + + template + std::pair emplace( + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))); + } + +#endif + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + template + iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) + { + return table_.emplace_hint(hint, boost::forward(args)...); + } + +#else + +#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) + iterator emplace_hint(const_iterator hint, boost::unordered::detail::empty_emplace = boost::unordered::detail::empty_emplace(), @@ -272,13 +307,6 @@ template class unordered_map #endif - template - std::pair emplace(BOOST_FWD_REF(A0) a0) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0))); - } - template iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0) { @@ -287,14 +315,6 @@ template class unordered_map boost::forward(a0))); } - template - std::pair emplace( - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1))); - } - template iterator emplace_hint( const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) @@ -304,15 +324,6 @@ template class unordered_map boost::forward(a0), boost::forward(a1))); } - template - std::pair emplace( - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))); - } - template iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) @@ -323,6 +334,10 @@ template class unordered_map boost::forward(a2))); } +#endif + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + #define BOOST_UNORDERED_EMPLACE(z, n, _) \ template \ std::pair emplace( \ @@ -971,16 +986,12 @@ template class unordered_multimap // emplace #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template iterator emplace(BOOST_FWD_REF(Args)... args) { return table_.emplace(boost::forward(args)...); } - template - iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) - { - return table_.emplace_hint(hint, boost::forward(args)...); - } #else #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) @@ -996,14 +1007,6 @@ template class unordered_multimap return this->emplace(boost::move(v)); } - iterator emplace_hint(const_iterator hint, - boost::unordered::detail::empty_emplace = - boost::unordered::detail::empty_emplace(), - value_type v = value_type()) - { - return this->emplace_hint(hint, boost::move(v)); - } - #endif template iterator emplace(BOOST_FWD_REF(A0) a0) @@ -1012,14 +1015,6 @@ template class unordered_multimap boost::forward(a0))); } - template - iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0) - { - return table_.emplace_hint( - hint, boost::unordered::detail::create_emplace_args( - boost::forward(a0))); - } - template iterator emplace(BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) { @@ -1027,15 +1022,6 @@ template class unordered_multimap boost::forward(a0), boost::forward(a1))); } - template - iterator emplace_hint( - const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) - { - return table_.emplace_hint( - hint, boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1))); - } - template iterator emplace( BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) @@ -1045,6 +1031,46 @@ template class unordered_multimap boost::forward(a2))); } +#endif + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + template + iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) + { + return table_.emplace_hint(hint, boost::forward(args)...); + } + +#else + +#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) + + iterator emplace_hint(const_iterator hint, + boost::unordered::detail::empty_emplace = + boost::unordered::detail::empty_emplace(), + value_type v = value_type()) + { + return this->emplace_hint(hint, boost::move(v)); + } + +#endif + + template + iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0) + { + return table_.emplace_hint( + hint, boost::unordered::detail::create_emplace_args( + boost::forward(a0))); + } + template + iterator emplace_hint( + const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) + { + return table_.emplace_hint( + hint, boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1))); + } + template iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) @@ -1055,6 +1081,10 @@ template class unordered_multimap boost::forward(a2))); } +#endif + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + #define BOOST_UNORDERED_EMPLACE(z, n, _) \ template \ iterator emplace(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 0bc240c1..aee65b41 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -232,17 +232,13 @@ template class unordered_set // emplace #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template std::pair emplace(BOOST_FWD_REF(Args)... args) { return table_.emplace(boost::forward(args)...); } - template - iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) - { - return table_.emplace_hint(hint, boost::forward(args)...); - } #else #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) @@ -259,6 +255,46 @@ template class unordered_set return this->emplace(boost::move(v)); } +#endif + + template + std::pair emplace(BOOST_FWD_REF(A0) a0) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0))); + } + + template + std::pair emplace( + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1))); + } + + template + std::pair emplace( + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))); + } + +#endif + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + template + iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) + { + return table_.emplace_hint(hint, boost::forward(args)...); + } + +#else + +#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) + iterator emplace_hint(const_iterator hint, boost::unordered::detail::empty_emplace = boost::unordered::detail::empty_emplace(), @@ -269,13 +305,6 @@ template class unordered_set #endif - template - std::pair emplace(BOOST_FWD_REF(A0) a0) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0))); - } - template iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0) { @@ -284,14 +313,6 @@ template class unordered_set boost::forward(a0))); } - template - std::pair emplace( - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1))); - } - template iterator emplace_hint( const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) @@ -301,15 +322,6 @@ template class unordered_set boost::forward(a0), boost::forward(a1))); } - template - std::pair emplace( - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))); - } - template iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) @@ -320,6 +332,10 @@ template class unordered_set boost::forward(a2))); } +#endif + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + #define BOOST_UNORDERED_EMPLACE(z, n, _) \ template \ std::pair emplace( \ @@ -703,11 +719,6 @@ template class unordered_multiset return table_.emplace(boost::forward(args)...); } - template - iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) - { - return table_.emplace_hint(hint, boost::forward(args)...); - } #else #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) @@ -723,6 +734,44 @@ template class unordered_multiset return this->emplace(boost::move(v)); } +#endif + + template iterator emplace(BOOST_FWD_REF(A0) a0) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0))); + } + + template + iterator emplace(BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1))); + } + + template + iterator emplace( + BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) + { + return table_.emplace(boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))); + } + +#endif + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + template + iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) + { + return table_.emplace_hint(hint, boost::forward(args)...); + } + +#else + +#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) + iterator emplace_hint(const_iterator hint, boost::unordered::detail::empty_emplace = boost::unordered::detail::empty_emplace(), @@ -733,12 +782,6 @@ template class unordered_multiset #endif - template iterator emplace(BOOST_FWD_REF(A0) a0) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0))); - } - template iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0) { @@ -747,13 +790,6 @@ template class unordered_multiset boost::forward(a0))); } - template - iterator emplace(BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1))); - } - template iterator emplace_hint( const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1) @@ -763,15 +799,6 @@ template class unordered_multiset boost::forward(a0), boost::forward(a1))); } - template - iterator emplace( - BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) - { - return table_.emplace(boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))); - } - template iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) @@ -782,6 +809,10 @@ template class unordered_multiset boost::forward(a2))); } +#endif + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + #define BOOST_UNORDERED_EMPLACE(z, n, _) \ template \ iterator emplace(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ From 5eb10fd0b235bc9e468e7f6f85ee6ecd26d45bec Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 07/16] Move extract into place --- include/boost/unordered/unordered_map.hpp | 52 +++++++++++------------ include/boost/unordered/unordered_set.hpp | 52 +++++++++++------------ 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 0a257b7e..ec3d891e 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -218,19 +218,6 @@ template class unordered_map size_type max_size() const BOOST_NOEXCEPT; - // extract - - node_type extract(const_iterator position) - { - return node_type( - table_.extract_by_iterator(position), table_.node_alloc()); - } - - node_type extract(const key_type& k) - { - return node_type(table_.extract_by_key(k), table_.node_alloc()); - } - // emplace #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) @@ -407,6 +394,19 @@ template class unordered_map void insert(std::initializer_list); #endif + // extract + + node_type extract(const_iterator position) + { + return node_type( + table_.extract_by_iterator(position), table_.node_alloc()); + } + + node_type extract(const key_type& k) + { + return node_type(table_.extract_by_key(k), table_.node_alloc()); + } + insert_return_type insert(BOOST_RV_REF(node_type) np) { insert_return_type result; @@ -970,19 +970,6 @@ template class unordered_multimap size_type max_size() const BOOST_NOEXCEPT; - // extract - - node_type extract(const_iterator position) - { - return node_type( - table_.extract_by_iterator(position), table_.node_alloc()); - } - - node_type extract(const key_type& k) - { - return node_type(table_.extract_by_key(k), table_.node_alloc()); - } - // emplace #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) @@ -1150,6 +1137,19 @@ template class unordered_multimap void insert(std::initializer_list); #endif + // extract + + node_type extract(const_iterator position) + { + return node_type( + table_.extract_by_iterator(position), table_.node_alloc()); + } + + node_type extract(const key_type& k) + { + return node_type(table_.extract_by_key(k), table_.node_alloc()); + } + iterator insert(BOOST_RV_REF(node_type) np) { return table_.move_insert_node_type(np); diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index aee65b41..d2497620 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -216,19 +216,6 @@ template class unordered_set size_type max_size() const BOOST_NOEXCEPT; - // extract - - node_type extract(const_iterator position) - { - return node_type( - table_.extract_by_iterator(position), table_.node_alloc()); - } - - node_type extract(const key_type& k) - { - return node_type(table_.extract_by_key(k), table_.node_alloc()); - } - // emplace #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) @@ -387,6 +374,19 @@ template class unordered_set void insert(std::initializer_list); #endif + // extract + + node_type extract(const_iterator position) + { + return node_type( + table_.extract_by_iterator(position), table_.node_alloc()); + } + + node_type extract(const key_type& k) + { + return node_type(table_.extract_by_key(k), table_.node_alloc()); + } + insert_return_type insert(BOOST_RV_REF(node_type) np) { insert_return_type result; @@ -698,19 +698,6 @@ template class unordered_multiset size_type max_size() const BOOST_NOEXCEPT; - // extract - - node_type extract(const_iterator position) - { - return node_type( - table_.extract_by_iterator(position), table_.node_alloc()); - } - - node_type extract(const key_type& k) - { - return node_type(table_.extract_by_key(k), table_.node_alloc()); - } - // emplace #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) @@ -860,6 +847,19 @@ template class unordered_multiset void insert(std::initializer_list); #endif + // extract + + node_type extract(const_iterator position) + { + return node_type( + table_.extract_by_iterator(position), table_.node_alloc()); + } + + node_type extract(const key_type& k) + { + return node_type(table_.extract_by_key(k), table_.node_alloc()); + } + iterator insert(BOOST_RV_REF(node_type) np) { return table_.move_insert_node_type(np); From 461ac96a2cd05c4df10efa0e8f822817873d654b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 08/16] Reorder insert_or_assign to match standard --- include/boost/unordered/unordered_map.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index ec3d891e..cfaa1a29 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -644,13 +644,6 @@ template class unordered_map return table_.insert_or_assign_impl(k, boost::forward(obj)); } - template - iterator insert_or_assign( - const_iterator, key_type const& k, BOOST_FWD_REF(M) obj) - { - return table_.insert_or_assign_impl(k, boost::forward(obj)).first; - } - template std::pair insert_or_assign( BOOST_RV_REF(key_type) k, BOOST_FWD_REF(M) obj) @@ -659,6 +652,13 @@ template class unordered_map boost::move(k), boost::forward(obj)); } + template + iterator insert_or_assign( + const_iterator, key_type const& k, BOOST_FWD_REF(M) obj) + { + return table_.insert_or_assign_impl(k, boost::forward(obj)).first; + } + template iterator insert_or_assign( const_iterator, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(M) obj) From bf7a65010c843495dddc487a8f7889f1d6745871 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 09/16] Add new erase(iterator) overloads Not for unordered_set/unordered_multiset as they use the same type for iterator and const_iterator. --- include/boost/unordered/unordered_map.hpp | 16 ++++++++++++ test/unordered/compile_map.cpp | 32 +++++++++++++++++++++++ test/unordered/compile_set.cpp | 32 +++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index cfaa1a29..61081e36 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -668,6 +668,7 @@ template class unordered_map .first; } + iterator erase(iterator); iterator erase(const_iterator); size_type erase(const key_type&); iterator erase(const_iterator, const_iterator); @@ -1169,6 +1170,7 @@ template class unordered_multimap public: #endif + iterator erase(iterator); iterator erase(const_iterator); size_type erase(const key_type&); iterator erase(const_iterator, const_iterator); @@ -1455,6 +1457,13 @@ void unordered_map::insert( } #endif +template +typename unordered_map::iterator +unordered_map::erase(iterator position) +{ + return table_.erase(position); +} + template typename unordered_map::iterator unordered_map::erase(const_iterator position) @@ -1866,6 +1875,13 @@ void unordered_multimap::insert( } #endif +template +typename unordered_multimap::iterator +unordered_multimap::erase(iterator position) +{ + return table_.erase(position); +} + template typename unordered_multimap::iterator unordered_multimap::erase(const_iterator position) diff --git a/test/unordered/compile_map.cpp b/test/unordered/compile_map.cpp index 1b099c70..6293dfb8 100644 --- a/test/unordered/compile_map.cpp +++ b/test/unordered/compile_map.cpp @@ -227,4 +227,36 @@ UNORDERED_AUTO_TEST(test2) unordered_map_member_test(multimap, map_value); } +// Test for ambiguity when using key convertible from iterator +// See LWG2059 + +struct lwg2059_key +{ + int value; + + template lwg2059_key(T v) : value(v) {} +}; + +std::size_t hash_value(lwg2059_key x) +{ + return static_cast(x.value); +} + +bool operator==(lwg2059_key x, lwg2059_key y) { return x.value == y.value; } + +UNORDERED_AUTO_TEST(lwg2059) +{ + { + boost::unordered_map x; + x.emplace(lwg2059_key(10), 5); + x.erase(x.begin()); + } + + { + boost::unordered_multimap x; + x.emplace(lwg2059_key(10), 5); + x.erase(x.begin()); + } +} + RUN_TESTS() diff --git a/test/unordered/compile_set.cpp b/test/unordered/compile_set.cpp index 3ea98703..e0a07737 100644 --- a/test/unordered/compile_set.cpp +++ b/test/unordered/compile_set.cpp @@ -290,4 +290,36 @@ UNORDERED_AUTO_TEST(destructible_tests) unordered_destructible_test(multiset); } +// Test for ambiguity when using key convertible from iterator +// See LWG2059 + +struct lwg2059_key +{ + int value; + + template lwg2059_key(T v) : value(v) {} +}; + +std::size_t hash_value(lwg2059_key x) +{ + return static_cast(x.value); +} + +bool operator==(lwg2059_key x, lwg2059_key y) { return x.value == y.value; } + +UNORDERED_AUTO_TEST(lwg2059) +{ + { + boost::unordered_set x; + x.emplace(lwg2059_key(10)); + x.erase(x.begin()); + } + + { + boost::unordered_multiset x; + x.emplace(lwg2059_key(10)); + x.erase(x.begin()); + } +} + RUN_TESTS() From 5167c970af485e1f6a730a5fb5678d04d69d9194 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 10/16] Swap order of swap/clear to match standard --- include/boost/unordered/unordered_map.hpp | 28 +++++++++++------------ include/boost/unordered/unordered_set.hpp | 20 ++++++++-------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 61081e36..4897f386 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -677,8 +677,8 @@ template class unordered_map BOOST_UNORDERED_DEPRECATED("Use erase instead") void erase_return_void(const_iterator it) { erase(it); } - void clear(); void swap(unordered_map&); + void clear(); template void merge(boost::unordered_map& source); @@ -1179,8 +1179,8 @@ template class unordered_multimap BOOST_UNORDERED_DEPRECATED("Use erase instead") void erase_return_void(const_iterator it) { erase(it); } - void clear(); void swap(unordered_multimap&); + void clear(); template void merge(boost::unordered_multimap& source); @@ -1485,18 +1485,18 @@ unordered_map::erase(const_iterator first, const_iterator last) return table_.erase_range(first, last); } -template -void unordered_map::clear() -{ - table_.clear(); -} - template void unordered_map::swap(unordered_map& other) { table_.swap(other.table_); } +template +void unordered_map::clear() +{ + table_.clear(); +} + template template void unordered_map::merge( @@ -1904,18 +1904,18 @@ unordered_multimap::erase( return table_.erase_range(first, last); } -template -void unordered_multimap::clear() -{ - table_.clear(); -} - template void unordered_multimap::swap(unordered_multimap& other) { table_.swap(other.table_); } +template +void unordered_multimap::clear() +{ + table_.clear(); +} + // observers template diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index d2497620..2cf710f5 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -416,8 +416,8 @@ template class unordered_set BOOST_UNORDERED_DEPRECATED("Use erase instead") void erase_return_void(const_iterator it) { erase(it); } - void clear(); void swap(unordered_set&); + void clear(); template void merge(boost::unordered_set& source); @@ -887,8 +887,8 @@ template class unordered_multiset BOOST_UNORDERED_DEPRECATED("Use erase instead") void erase_return_void(const_iterator it) { erase(it); } - void clear(); void swap(unordered_multiset&); + void clear(); template void merge(boost::unordered_multiset& source); @@ -1174,6 +1174,12 @@ typename unordered_set::iterator unordered_set::erase( return table_.erase_range(first, last); } +template +void unordered_set::swap(unordered_set& other) +{ + table_.swap(other.table_); +} + template void unordered_set::clear() { @@ -1181,9 +1187,9 @@ void unordered_set::clear() } template -void unordered_set::swap(unordered_set& other) +void unordered_multiset::clear() { - table_.swap(other.table_); + table_.clear(); } // observers @@ -1539,12 +1545,6 @@ unordered_multiset::erase(const_iterator first, const_iterator last) return table_.erase_range(first, last); } -template -void unordered_multiset::clear() -{ - table_.clear(); -} - template void unordered_multiset::swap(unordered_multiset& other) { From 85a834cf62940da0203eb53f1d54a1e822b57308 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 11/16] Comment on changes needed for C++17 support --- include/boost/unordered/unordered_map.hpp | 16 ++++++++++++++++ include/boost/unordered/unordered_set.hpp | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 4897f386..f12666c4 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -678,6 +678,10 @@ template class unordered_map void erase_return_void(const_iterator it) { erase(it); } void swap(unordered_map&); + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) void clear(); template @@ -1180,6 +1184,10 @@ template class unordered_multimap void erase_return_void(const_iterator it) { erase(it); } void swap(unordered_multimap&); + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) void clear(); template @@ -1487,6 +1495,10 @@ unordered_map::erase(const_iterator first, const_iterator last) template void unordered_map::swap(unordered_map& other) +// C++17 support: BOOST_NOEXCEPT_IF( +// value_allocator_traits::is_always_equal::value && +// is_nothrow_move_assignable_v && +// is_nothrow_move_assignable_v

) { table_.swap(other.table_); } @@ -1906,6 +1918,10 @@ unordered_multimap::erase( template void unordered_multimap::swap(unordered_multimap& other) +// C++17 support: BOOST_NOEXCEPT_IF( +// value_allocator_traits::is_always_equal::value && +// is_nothrow_move_assignable_v && +// is_nothrow_move_assignable_v

) { table_.swap(other.table_); } diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 2cf710f5..58731b43 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -417,6 +417,10 @@ template class unordered_set void erase_return_void(const_iterator it) { erase(it); } void swap(unordered_set&); + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) void clear(); template @@ -888,6 +892,10 @@ template class unordered_multiset void erase_return_void(const_iterator it) { erase(it); } void swap(unordered_multiset&); + // C++17 support: BOOST_NOEXCEPT_IF( + // value_allocator_traits::is_always_equal::value && + // is_nothrow_move_assignable_v && + // is_nothrow_move_assignable_v

) void clear(); template @@ -1176,6 +1184,10 @@ typename unordered_set::iterator unordered_set::erase( template void unordered_set::swap(unordered_set& other) +// C++17 support: BOOST_NOEXCEPT_IF( +// value_allocator_traits::is_always_equal::value && +// is_nothrow_move_assignable_v && +// is_nothrow_move_assignable_v

) { table_.swap(other.table_); } @@ -1547,6 +1559,10 @@ unordered_multiset::erase(const_iterator first, const_iterator last) template void unordered_multiset::swap(unordered_multiset& other) +// C++17 support: BOOST_NOEXCEPT_IF( +// value_allocator_traits::is_always_equal::value && +// is_nothrow_move_assignable_v && +// is_nothrow_move_assignable_v

) { table_.swap(other.table_); } From 9cd673c71d82ae4e64e164527071a99548c0076a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 12/16] Specify clear as noexcept --- include/boost/unordered/unordered_map.hpp | 8 ++++---- include/boost/unordered/unordered_set.hpp | 8 ++++---- test/unordered/compile_tests.hpp | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index f12666c4..51d37e6b 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -682,7 +682,7 @@ template class unordered_map // value_allocator_traits::is_always_equal::value && // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) - void clear(); + void clear() BOOST_NOEXCEPT; template void merge(boost::unordered_map& source); @@ -1188,7 +1188,7 @@ template class unordered_multimap // value_allocator_traits::is_always_equal::value && // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) - void clear(); + void clear() BOOST_NOEXCEPT; template void merge(boost::unordered_multimap& source); @@ -1504,7 +1504,7 @@ void unordered_map::swap(unordered_map& other) } template -void unordered_map::clear() +void unordered_map::clear() BOOST_NOEXCEPT { table_.clear(); } @@ -1927,7 +1927,7 @@ void unordered_multimap::swap(unordered_multimap& other) } template -void unordered_multimap::clear() +void unordered_multimap::clear() BOOST_NOEXCEPT { table_.clear(); } diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 58731b43..6300d6d3 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -421,7 +421,7 @@ template class unordered_set // value_allocator_traits::is_always_equal::value && // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) - void clear(); + void clear() BOOST_NOEXCEPT; template void merge(boost::unordered_set& source); @@ -896,7 +896,7 @@ template class unordered_multiset // value_allocator_traits::is_always_equal::value && // is_nothrow_move_assignable_v && // is_nothrow_move_assignable_v

) - void clear(); + void clear() BOOST_NOEXCEPT; template void merge(boost::unordered_multiset& source); @@ -1193,13 +1193,13 @@ void unordered_set::swap(unordered_set& other) } template -void unordered_set::clear() +void unordered_set::clear() BOOST_NOEXCEPT { table_.clear(); } template -void unordered_multiset::clear() +void unordered_multiset::clear() BOOST_NOEXCEPT { table_.clear(); } diff --git a/test/unordered/compile_tests.hpp b/test/unordered/compile_tests.hpp index 45ad2111..c676f2d5 100644 --- a/test/unordered/compile_tests.hpp +++ b/test/unordered/compile_tests.hpp @@ -554,6 +554,7 @@ void unordered_test(X& x, Key& k, Hash& hf, Pred& eq) const_iterator q1 = a.cbegin(), q2 = a.cend(); test::check_return_type::equals(a.erase(q1, q2)); + TEST_NOEXCEPT_EXPR(a.clear()); a.clear(); X const b; From fedf5336990f617ab86d46cff027c3a874323db4 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 13/16] Move index functions into place --- include/boost/unordered/unordered_map.hpp | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 51d37e6b..7b2ff6fc 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -707,10 +707,6 @@ template class unordered_map hasher hash_function() const; key_equal key_eq() const; - mapped_type& operator[](const key_type&); - mapped_type& at(const key_type&); - mapped_type const& at(const key_type&) const; - // lookup iterator find(const key_type&); @@ -732,6 +728,10 @@ template class unordered_map std::pair equal_range( const key_type&) const; + mapped_type& operator[](const key_type&); + mapped_type& at(const key_type&); + mapped_type const& at(const key_type&) const; + // bucket interface size_type bucket_count() const BOOST_NOEXCEPT @@ -1563,27 +1563,6 @@ unordered_map::key_eq() const return table_.key_eq(); } -template -typename unordered_map::mapped_type& - unordered_map::operator[](const key_type& k) -{ - return table_.try_emplace_impl(k).first->second; -} - -template -typename unordered_map::mapped_type& -unordered_map::at(const key_type& k) -{ - return table_.at(k).second; -} - -template -typename unordered_map::mapped_type const& -unordered_map::at(const key_type& k) const -{ - return table_.at(k).second; -} - // lookup template @@ -1641,6 +1620,27 @@ unordered_map::equal_range(const key_type& k) const return table_.equal_range(k); } +template +typename unordered_map::mapped_type& + unordered_map::operator[](const key_type& k) +{ + return table_.try_emplace_impl(k).first->second; +} + +template +typename unordered_map::mapped_type& +unordered_map::at(const key_type& k) +{ + return table_.at(k).second; +} + +template +typename unordered_map::mapped_type const& +unordered_map::at(const key_type& k) const +{ + return table_.at(k).second; +} + template typename unordered_map::size_type unordered_map::bucket_size(size_type n) const From de5373413be4f2b7f005dfcbb0cee6f6d72d0d2b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 14/16] Missing rvalue overload of at --- include/boost/unordered/unordered_map.hpp | 8 ++++++++ test/unordered/compile_tests.hpp | 1 + 2 files changed, 9 insertions(+) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 7b2ff6fc..f40d03d4 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -729,6 +729,7 @@ template class unordered_map const key_type&) const; mapped_type& operator[](const key_type&); + mapped_type& operator[](BOOST_RV_REF(key_type)); mapped_type& at(const key_type&); mapped_type const& at(const key_type&) const; @@ -1627,6 +1628,13 @@ typename unordered_map::mapped_type& return table_.try_emplace_impl(k).first->second; } +template +typename unordered_map::mapped_type& + unordered_map::operator[](BOOST_RV_REF(key_type) k) +{ + return table_.try_emplace_impl(boost::move(k)).first->second; +} + template typename unordered_map::mapped_type& unordered_map::at(const key_type& k) diff --git a/test/unordered/compile_tests.hpp b/test/unordered/compile_tests.hpp index c676f2d5..12759c16 100644 --- a/test/unordered/compile_tests.hpp +++ b/test/unordered/compile_tests.hpp @@ -422,6 +422,7 @@ void unordered_map_functions(X&, Key const& k, T const& v) X a; test::check_return_type::equals_ref(a[k]); + test::check_return_type::equals_ref(a[rvalue(k)]); test::check_return_type::equals_ref(a.at(k)); test::check_return_type >::equals( a.try_emplace(k, v)); From f3b179d451c92bce053fc67f514dff2931db378b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 15/16] Remove pointless duplication of move constructor --- include/boost/unordered/unordered_map.hpp | 18 ++++-------------- include/boost/unordered/unordered_set.hpp | 18 ++++-------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index f40d03d4..a991950c 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -93,18 +93,13 @@ template class unordered_map unordered_map(unordered_map const&); -#if defined(BOOST_UNORDERED_USE_MOVE) +#if defined(BOOST_UNORDERED_USE_MOVE) || \ + !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_map(BOOST_RV_REF(unordered_map) other) BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) : table_(other.table_, boost::unordered::detail::move_tag()) { } -#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - unordered_map(unordered_map&& other) - BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) - : table_(other.table_, boost::unordered::detail::move_tag()) - { - } #endif explicit unordered_map(allocator_type const&); @@ -850,18 +845,13 @@ template class unordered_multimap unordered_multimap(unordered_multimap const&); -#if defined(BOOST_UNORDERED_USE_MOVE) +#if defined(BOOST_UNORDERED_USE_MOVE) || \ + !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_multimap(BOOST_RV_REF(unordered_multimap) other) BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) : table_(other.table_, boost::unordered::detail::move_tag()) { } -#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - unordered_multimap(unordered_multimap&& other) - BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) - : table_(other.table_, boost::unordered::detail::move_tag()) - { - } #endif explicit unordered_multimap(allocator_type const&); diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 6300d6d3..747f00f5 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -91,18 +91,13 @@ template class unordered_set unordered_set(unordered_set const&); -#if defined(BOOST_UNORDERED_USE_MOVE) +#if defined(BOOST_UNORDERED_USE_MOVE) || \ + !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_set(BOOST_RV_REF(unordered_set) other) BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) : table_(other.table_, boost::unordered::detail::move_tag()) { } -#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - unordered_set(unordered_set&& other) - BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) - : table_(other.table_, boost::unordered::detail::move_tag()) - { - } #endif explicit unordered_set(allocator_type const&); @@ -576,18 +571,13 @@ template class unordered_multiset unordered_multiset(unordered_multiset const&); -#if defined(BOOST_UNORDERED_USE_MOVE) +#if defined(BOOST_UNORDERED_USE_MOVE) || \ + !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_multiset(BOOST_RV_REF(unordered_multiset) other) BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) : table_(other.table_, boost::unordered::detail::move_tag()) { } -#elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - unordered_multiset(unordered_multiset&& other) - BOOST_NOEXCEPT_IF(table::nothrow_move_constructible) - : table_(other.table_, boost::unordered::detail::move_tag()) - { - } #endif explicit unordered_multiset(allocator_type const&); From b067e6573149124069634cee02015eb1b89101a8 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH 16/16] Clean table forward declarations --- include/boost/unordered/detail/implementation.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 3b4c3a47..c08adf29 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -168,17 +168,16 @@ namespace detail { template struct table; template struct bucket; struct ptr_bucket; + template struct table_unique; template struct table_equiv; template struct unique_node; template struct ptr_node; -template struct table_unique; +template struct node_algo; template struct grouped_node; template struct grouped_ptr_node; -template struct table_equiv; -template struct node_algo; template struct grouped_node_algo; static const float minimum_max_load_factor = 1e-3f;