From 20e923ba0de920d00012aea4221ab4533b90528a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 4 Jun 2011 16:17:07 +0000 Subject: [PATCH] Unordered: Move the implementation into a namespace. Although it typically won't prevent ADL, because of boost::hash. [SVN r72391] --- .../unordered/detail/allocator_helpers.hpp | 2 +- include/boost/unordered/detail/buckets.hpp | 20 +---- include/boost/unordered/detail/equivalent.hpp | 2 +- .../boost/unordered/detail/extract_key.hpp | 2 +- include/boost/unordered/detail/fwd.hpp | 87 +++++++++++++++++++ include/boost/unordered/detail/node.hpp | 2 +- include/boost/unordered/detail/table.hpp | 13 ++- include/boost/unordered/detail/unique.hpp | 2 +- include/boost/unordered/detail/util.hpp | 2 +- include/boost/unordered/unordered_map.hpp | 26 ++---- include/boost/unordered/unordered_map_fwd.hpp | 40 +-------- include/boost/unordered/unordered_set.hpp | 25 ++---- include/boost/unordered/unordered_set_fwd.hpp | 38 +------- 13 files changed, 129 insertions(+), 132 deletions(-) create mode 100644 include/boost/unordered/detail/fwd.hpp diff --git a/include/boost/unordered/detail/allocator_helpers.hpp b/include/boost/unordered/detail/allocator_helpers.hpp index 7393df1e..417c0870 100644 --- a/include/boost/unordered/detail/allocator_helpers.hpp +++ b/include/boost/unordered/detail/allocator_helpers.hpp @@ -1,5 +1,5 @@ -// Copyright 2005-2009 Daniel James. +// Copyright 2005-2011 Daniel James. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/unordered/detail/buckets.hpp b/include/boost/unordered/detail/buckets.hpp index 2469b03a..7c41397d 100644 --- a/include/boost/unordered/detail/buckets.hpp +++ b/include/boost/unordered/detail/buckets.hpp @@ -1,6 +1,6 @@ // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. -// Copyright (C) 2005-2009 Daniel James +// Copyright (C) 2005-2011 Daniel James // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -635,24 +635,6 @@ namespace boost { namespace unordered { namespace detail { } } } - - /////////////////////////////////////////////////////////////////// - // - // Iterators - - // iterator_access is used to access the internal iterator without - // making it publicly available. - - class iterator_access - { - public: - template - static BOOST_DEDUCED_TYPENAME Iterator::node_ptr const& - get(Iterator const& it) - { - return it.node_; - } - }; }}} #endif diff --git a/include/boost/unordered/detail/equivalent.hpp b/include/boost/unordered/detail/equivalent.hpp index e650bf7d..78ad2cc5 100644 --- a/include/boost/unordered/detail/equivalent.hpp +++ b/include/boost/unordered/detail/equivalent.hpp @@ -1,6 +1,6 @@ // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. -// Copyright (C) 2005-2009 Daniel James +// Copyright (C) 2005-2011 Daniel James // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/unordered/detail/extract_key.hpp b/include/boost/unordered/detail/extract_key.hpp index ad90f940..97c4f4d0 100644 --- a/include/boost/unordered/detail/extract_key.hpp +++ b/include/boost/unordered/detail/extract_key.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2005-2009 Daniel James +// Copyright (C) 2005-2011 Daniel James // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/unordered/detail/fwd.hpp b/include/boost/unordered/detail/fwd.hpp new file mode 100644 index 00000000..c923ace3 --- /dev/null +++ b/include/boost/unordered/detail/fwd.hpp @@ -0,0 +1,87 @@ + +// Copyright (C) 2008-2011 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_UNORDERED_FWD_HPP_INCLUDED +#define BOOST_UNORDERED_FWD_HPP_INCLUDED + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include +#include +#include +#include + +namespace boost +{ +namespace unordered +{ + template , + class P = std::equal_to, + class A = std::allocator > > + class unordered_map; + template + inline bool operator==(unordered_map const&, + unordered_map const&); + template + inline bool operator!=(unordered_map const&, + unordered_map const&); + template + inline void swap(unordered_map&, + unordered_map&); + + template , + class P = std::equal_to, + class A = std::allocator > > + class unordered_multimap; + template + inline bool operator==(unordered_multimap const&, + unordered_multimap const&); + template + inline bool operator!=(unordered_multimap const&, + unordered_multimap const&); + template + inline void swap(unordered_multimap&, + unordered_multimap&); + + template , + class P = std::equal_to, + class A = std::allocator > + class unordered_set; + template + inline bool operator==(unordered_set const&, + unordered_set const&); + template + inline bool operator!=(unordered_set const&, + unordered_set const&); + template + inline void swap(unordered_set &m1, + unordered_set &m2); + + template , + class P = std::equal_to, + class A = std::allocator > + class unordered_multiset; + template + inline bool operator==(unordered_multiset const&, + unordered_multiset const&); + template + inline bool operator!=(unordered_multiset const&, + unordered_multiset const&); + template + inline void swap(unordered_multiset &m1, + unordered_multiset &m2); + +} +} + +#endif diff --git a/include/boost/unordered/detail/node.hpp b/include/boost/unordered/detail/node.hpp index 1a500029..7867bbad 100644 --- a/include/boost/unordered/detail/node.hpp +++ b/include/boost/unordered/detail/node.hpp @@ -1,6 +1,6 @@ // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. -// Copyright (C) 2005-2009 Daniel James +// Copyright (C) 2005-2011 Daniel James // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index f4bb23f3..d728580e 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -1,6 +1,6 @@ // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. -// Copyright (C) 2005-2009 Daniel James +// Copyright (C) 2005-2011 Daniel James // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -801,7 +801,16 @@ namespace boost { namespace unordered { namespace iterator_detail { typedef ::boost::unordered::iterator_detail::iterator iterator; friend class ::boost::unordered::iterator_detail::iterator; - friend class ::boost::unordered::detail::iterator_access; + + template + friend class ::boost::unordered::unordered_map; + template + friend class ::boost::unordered::unordered_multimap; + template + friend class ::boost::unordered::unordered_set; + template + friend class ::boost::unordered::unordered_multiset; + node_ptr node_; public: diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index 2a1224b2..894406cf 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -1,6 +1,6 @@ // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. -// Copyright (C) 2005-2010 Daniel James +// Copyright (C) 2005-2011 Daniel James // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/unordered/detail/util.hpp b/include/boost/unordered/detail/util.hpp index 801df188..fa86c65b 100644 --- a/include/boost/unordered/detail/util.hpp +++ b/include/boost/unordered/detail/util.hpp @@ -1,6 +1,6 @@ // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. -// Copyright (C) 2005-2009 Daniel James +// Copyright (C) 2005-2011 Daniel James // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 8b9e5e6e..251ae239 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -1,6 +1,6 @@ // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. -// Copyright (C) 2005-2009 Daniel James. +// Copyright (C) 2005-2011 Daniel James. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -37,6 +37,8 @@ #endif namespace boost +{ +namespace unordered { template class unordered_map @@ -93,12 +95,6 @@ namespace boost table table_; - BOOST_DEDUCED_TYPENAME types::node_ptr const& - get(const_iterator const& it) - { - return ::boost::unordered::detail::iterator_access::get(it); - } - public: // construct/destroy/copy @@ -425,12 +421,6 @@ namespace boost table table_; - BOOST_DEDUCED_TYPENAME types::node_ptr const& - get(const_iterator const& it) - { - return ::boost::unordered::detail::iterator_access::get(it); - } - public: // construct/destroy/copy @@ -957,7 +947,7 @@ namespace boost BOOST_DEDUCED_TYPENAME unordered_map::iterator unordered_map::erase(const_iterator position) { - return iterator(table_.erase(get(position))); + return iterator(table_.erase(position.node_)); } template @@ -972,7 +962,7 @@ namespace boost unordered_map::erase( const_iterator first, const_iterator last) { - return iterator(table_.erase_range(get(first), get(last))); + return iterator(table_.erase_range(first.node_, last.node_)); } template @@ -1411,7 +1401,7 @@ namespace boost BOOST_DEDUCED_TYPENAME unordered_multimap::iterator unordered_multimap::erase(const_iterator position) { - return iterator(table_.erase(get(position))); + return iterator(table_.erase(position.node_)); } template @@ -1426,7 +1416,7 @@ namespace boost unordered_multimap::erase( const_iterator first, const_iterator last) { - return iterator(table_.erase_range(get(first), get(last))); + return iterator(table_.erase_range(first.node_, last.node_)); } template @@ -1584,7 +1574,7 @@ namespace boost m1.swap(m2); } - +} // namespace unordered } // namespace boost #if defined(BOOST_MSVC) diff --git a/include/boost/unordered/unordered_map_fwd.hpp b/include/boost/unordered/unordered_map_fwd.hpp index edecc5d9..ad4693e9 100644 --- a/include/boost/unordered/unordered_map_fwd.hpp +++ b/include/boost/unordered/unordered_map_fwd.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2008-2009 Daniel James. +// Copyright (C) 2008-2011 Daniel James. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,44 +10,12 @@ # pragma once #endif -#include -#include -#include -#include +#include namespace boost { - template , - class P = std::equal_to, - class A = std::allocator > > - class unordered_map; - template - inline bool operator==(unordered_map const&, - unordered_map const&); - template - inline bool operator!=(unordered_map const&, - unordered_map const&); - template - inline void swap(unordered_map&, - unordered_map&); - - template , - class P = std::equal_to, - class A = std::allocator > > - class unordered_multimap; - template - inline bool operator==(unordered_multimap const&, - unordered_multimap const&); - template - inline bool operator!=(unordered_multimap const&, - unordered_multimap const&); - template - inline void swap(unordered_multimap&, - unordered_multimap&); + using ::boost::unordered::unordered_map; + using ::boost::unordered::unordered_multimap; } #endif diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index fae9a000..4f4b0675 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -1,6 +1,6 @@ // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. -// Copyright (C) 2005-2009 Daniel James. +// Copyright (C) 2005-2011 Daniel James. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -37,6 +37,8 @@ #endif namespace boost +{ +namespace unordered { template class unordered_set @@ -90,12 +92,6 @@ namespace boost #endif table table_; - - BOOST_DEDUCED_TYPENAME types::node_ptr const& - get(const_iterator const& it) - { - return ::boost::unordered::detail::iterator_access::get(it); - } public: @@ -402,12 +398,6 @@ namespace boost #endif table table_; - - BOOST_DEDUCED_TYPENAME types::node_ptr const& - get(const_iterator const& it) - { - return ::boost::unordered::detail::iterator_access::get(it); - } public: @@ -919,7 +909,7 @@ namespace boost BOOST_DEDUCED_TYPENAME unordered_set::iterator unordered_set::erase(const_iterator position) { - return iterator(table_.erase(get(position))); + return iterator(table_.erase(position.node_)); } template @@ -933,7 +923,7 @@ namespace boost BOOST_DEDUCED_TYPENAME unordered_set::iterator unordered_set::erase(const_iterator first, const_iterator last) { - return iterator(table_.erase_range(get(first), get(last))); + return iterator(table_.erase_range(first.node_, last.node_)); } template @@ -1318,7 +1308,7 @@ namespace boost BOOST_DEDUCED_TYPENAME unordered_multiset::iterator unordered_multiset::erase(const_iterator position) { - return iterator(table_.erase(get(position))); + return iterator(table_.erase(position.node_)); } template @@ -1332,7 +1322,7 @@ namespace boost BOOST_DEDUCED_TYPENAME unordered_multiset::iterator unordered_multiset::erase(const_iterator first, const_iterator last) { - return iterator(table_.erase_range(get(first), get(last))); + return iterator(table_.erase_range(first.node_, last.node_)); } template @@ -1461,6 +1451,7 @@ namespace boost m1.swap(m2); } +} // namespace unordered } // namespace boost #if defined(BOOST_MSVC) diff --git a/include/boost/unordered/unordered_set_fwd.hpp b/include/boost/unordered/unordered_set_fwd.hpp index fead1243..b1737cbb 100644 --- a/include/boost/unordered/unordered_set_fwd.hpp +++ b/include/boost/unordered/unordered_set_fwd.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2008-2009 Daniel James. +// Copyright (C) 2008-2011 Daniel James. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,42 +10,12 @@ # pragma once #endif -#include -#include -#include -#include +#include namespace boost { - template , - class P = std::equal_to, - class A = std::allocator > - class unordered_set; - template - inline bool operator==(unordered_set const&, - unordered_set const&); - template - inline bool operator!=(unordered_set const&, - unordered_set const&); - template - inline void swap(unordered_set &m1, - unordered_set &m2); - - template , - class P = std::equal_to, - class A = std::allocator > - class unordered_multiset; - template - inline bool operator==(unordered_multiset const&, - unordered_multiset const&); - template - inline bool operator!=(unordered_multiset const&, - unordered_multiset const&); - template - inline void swap(unordered_multiset &m1, - unordered_multiset &m2); + using ::boost::unordered::unordered_set; + using ::boost::unordered::unordered_multiset; } #endif