From e0227618bba0bbc92cf008736a28f0b3d231c8a7 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 17 May 2017 16:46:56 +0100 Subject: [PATCH] Move a few things around to match the order in the standard --- include/boost/unordered/unordered_map.hpp | 106 +++++++++++----------- include/boost/unordered/unordered_set.hpp | 18 ++-- 2 files changed, 60 insertions(+), 64 deletions(-) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index c8bd5bb4..30ebe4cd 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -45,8 +45,8 @@ template class unordered_map public: typedef K key_type; - typedef std::pair value_type; typedef T mapped_type; + typedef std::pair value_type; typedef H hasher; typedef P key_equal; typedef A allocator_type; @@ -68,10 +68,10 @@ template class unordered_map typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; - typedef typename table::cl_iterator const_local_iterator; - typedef typename table::l_iterator local_iterator; - typedef typename table::c_iterator const_iterator; typedef typename table::iterator iterator; + typedef typename table::c_iterator const_iterator; + typedef typename table::l_iterator local_iterator; + typedef typename table::cl_iterator const_local_iterator; typedef typename types::node_type node_type; typedef typename types::insert_return_type insert_return_type; @@ -463,14 +463,6 @@ template class unordered_map return table_.try_emplace_unique(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_unique( - hint, k, boost::forward(args)...); - } - template std::pair try_emplace( BOOST_RV_REF(key_type) k, BOOST_FWD_REF(Args)... args) @@ -479,6 +471,14 @@ template class unordered_map boost::move(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_unique( + hint, k, boost::forward(args)...); + } + template iterator try_emplace(const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(Args)... args) @@ -539,36 +539,6 @@ template class unordered_map boost::forward(a2))); } - // try_emplace(const_iterator hint, key const&, Args&&...) - - template - iterator try_emplace( - const_iterator hint, key_type const& k, BOOST_FWD_REF(A0) a0) - { - return table_.try_emplace_hint_unique( - hint, 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, BOOST_FWD_REF(A1) a1) - { - return table_.try_emplace_hint_unique( - hint, 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, BOOST_FWD_REF(A2) a2) - { - return table_.try_emplace_hint_unique( - hint, k, boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))); - } - // try_emplace(key&&, Args&&...) template @@ -600,6 +570,36 @@ template class unordered_map boost::forward(a2))); } + // try_emplace(const_iterator hint, key const&, Args&&...) + + template + iterator try_emplace( + const_iterator hint, key_type const& k, BOOST_FWD_REF(A0) a0) + { + return table_.try_emplace_hint_unique( + hint, 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, BOOST_FWD_REF(A1) a1) + { + return table_.try_emplace_hint_unique( + hint, 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, BOOST_FWD_REF(A2) a2) + { + return table_.try_emplace_hint_unique( + hint, k, boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))); + } + // try_emplace(const_iterator hint, key&&, Args&&...) template @@ -644,19 +644,19 @@ template class unordered_map } \ \ template \ - iterator try_emplace(const_iterator hint, key_type const& k, \ + std::pair try_emplace(BOOST_RV_REF(key_type) k, \ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ { \ - return table_.try_emplace_hint_unique(hint, k, \ + return table_.try_emplace_unique(boost::move(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, \ + iterator try_emplace(const_iterator hint, key_type const& k, \ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \ { \ - return table_.try_emplace_unique(boost::move(k), \ + return table_.try_emplace_hint_unique(hint, k, \ boost::unordered::detail::create_emplace_args(BOOST_PP_ENUM_##z( \ n, BOOST_UNORDERED_CALL_FORWARD, a))); \ } \ @@ -822,9 +822,8 @@ template class unordered_map // hash policy - float max_load_factor() const BOOST_NOEXCEPT { return table_.mlf_; } - float load_factor() const BOOST_NOEXCEPT; + float max_load_factor() const BOOST_NOEXCEPT { return table_.mlf_; } void max_load_factor(float) BOOST_NOEXCEPT; void rehash(size_type); void reserve(size_type); @@ -847,8 +846,8 @@ template class unordered_multimap public: typedef K key_type; - typedef std::pair value_type; typedef T mapped_type; + typedef std::pair value_type; typedef H hasher; typedef P key_equal; typedef A allocator_type; @@ -870,10 +869,10 @@ template class unordered_multimap typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; - typedef typename table::cl_iterator const_local_iterator; - typedef typename table::l_iterator local_iterator; - typedef typename table::c_iterator const_iterator; typedef typename table::iterator iterator; + typedef typename table::c_iterator const_iterator; + typedef typename table::l_iterator local_iterator; + typedef typename table::cl_iterator const_local_iterator; typedef typename types::node_type node_type; private: @@ -1352,9 +1351,8 @@ template class unordered_multimap // hash policy - float max_load_factor() const BOOST_NOEXCEPT { return table_.mlf_; } - float load_factor() const BOOST_NOEXCEPT; + float max_load_factor() const BOOST_NOEXCEPT { return table_.mlf_; } void max_load_factor(float) BOOST_NOEXCEPT; void rehash(size_type); void reserve(size_type); diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index f2be1176..03bcf9a4 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -66,10 +66,10 @@ template class unordered_set typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; - typedef typename table::cl_iterator const_local_iterator; - typedef typename table::l_iterator local_iterator; - typedef typename table::c_iterator const_iterator; typedef typename table::iterator iterator; + typedef typename table::c_iterator const_iterator; + typedef typename table::l_iterator local_iterator; + typedef typename table::cl_iterator const_local_iterator; typedef typename types::node_type node_type; typedef typename types::insert_return_type insert_return_type; @@ -529,9 +529,8 @@ template class unordered_set // hash policy - float max_load_factor() const BOOST_NOEXCEPT { return table_.mlf_; } - float load_factor() const BOOST_NOEXCEPT; + float max_load_factor() const BOOST_NOEXCEPT { return table_.mlf_; } void max_load_factor(float) BOOST_NOEXCEPT; void rehash(size_type); void reserve(size_type); @@ -576,10 +575,10 @@ template class unordered_multiset typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; - typedef typename table::cl_iterator const_local_iterator; - typedef typename table::l_iterator local_iterator; - typedef typename table::c_iterator const_iterator; typedef typename table::iterator iterator; + typedef typename table::c_iterator const_iterator; + typedef typename table::l_iterator local_iterator; + typedef typename table::cl_iterator const_local_iterator; typedef typename types::node_type node_type; private: @@ -1032,9 +1031,8 @@ template class unordered_multiset // hash policy - float max_load_factor() const BOOST_NOEXCEPT { return table_.mlf_; } - float load_factor() const BOOST_NOEXCEPT; + float max_load_factor() const BOOST_NOEXCEPT { return table_.mlf_; } void max_load_factor(float) BOOST_NOEXCEPT; void rehash(size_type); void reserve(size_type);