Unordered: Move the implementation into a namespace.

Although it typically won't prevent ADL, because of boost::hash.

[SVN r72391]
This commit is contained in:
Daniel James
2011-06-04 16:17:07 +00:00
parent 4777eaf367
commit 20e923ba0d
13 changed files with 129 additions and 132 deletions

View File

@ -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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. // 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 // 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) // 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 <class Iterator>
static BOOST_DEDUCED_TYPENAME Iterator::node_ptr const&
get(Iterator const& it)
{
return it.node_;
}
};
}}} }}}
#endif #endif

View File

@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. // 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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

View File

@ -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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

View File

@ -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 <boost/config.hpp>
#include <memory>
#include <functional>
#include <boost/functional/hash_fwd.hpp>
namespace boost
{
namespace unordered
{
template <class K,
class T,
class H = hash<K>,
class P = std::equal_to<K>,
class A = std::allocator<std::pair<const K, T> > >
class unordered_map;
template <class K, class T, class H, class P, class A>
inline bool operator==(unordered_map<K, T, H, P, A> const&,
unordered_map<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
inline bool operator!=(unordered_map<K, T, H, P, A> const&,
unordered_map<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
inline void swap(unordered_map<K, T, H, P, A>&,
unordered_map<K, T, H, P, A>&);
template <class K,
class T,
class H = hash<K>,
class P = std::equal_to<K>,
class A = std::allocator<std::pair<const K, T> > >
class unordered_multimap;
template <class K, class T, class H, class P, class A>
inline bool operator==(unordered_multimap<K, T, H, P, A> const&,
unordered_multimap<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
inline bool operator!=(unordered_multimap<K, T, H, P, A> const&,
unordered_multimap<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
inline void swap(unordered_multimap<K, T, H, P, A>&,
unordered_multimap<K, T, H, P, A>&);
template <class T,
class H = hash<T>,
class P = std::equal_to<T>,
class A = std::allocator<T> >
class unordered_set;
template <class T, class H, class P, class A>
inline bool operator==(unordered_set<T, H, P, A> const&,
unordered_set<T, H, P, A> const&);
template <class T, class H, class P, class A>
inline bool operator!=(unordered_set<T, H, P, A> const&,
unordered_set<T, H, P, A> const&);
template <class T, class H, class P, class A>
inline void swap(unordered_set<T, H, P, A> &m1,
unordered_set<T, H, P, A> &m2);
template <class T,
class H = hash<T>,
class P = std::equal_to<T>,
class A = std::allocator<T> >
class unordered_multiset;
template <class T, class H, class P, class A>
inline bool operator==(unordered_multiset<T, H, P, A> const&,
unordered_multiset<T, H, P, A> const&);
template <class T, class H, class P, class A>
inline bool operator!=(unordered_multiset<T, H, P, A> const&,
unordered_multiset<T, H, P, A> const&);
template <class T, class H, class P, class A>
inline void swap(unordered_multiset<T, H, P, A> &m1,
unordered_multiset<T, H, P, A> &m2);
}
}
#endif

View File

@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. // 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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. // 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 // 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) // 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<A, Unique> typedef ::boost::unordered::iterator_detail::iterator<A, Unique>
iterator; iterator;
friend class ::boost::unordered::iterator_detail::iterator<A, Unique>; friend class ::boost::unordered::iterator_detail::iterator<A, Unique>;
friend class ::boost::unordered::detail::iterator_access;
template <class K, class T, class H, class P, class A2>
friend class ::boost::unordered::unordered_map;
template <class K, class T, class H, class P, class A2>
friend class ::boost::unordered::unordered_multimap;
template <class T, class H, class P, class A2>
friend class ::boost::unordered::unordered_set;
template <class T, class H, class P, class A2>
friend class ::boost::unordered::unordered_multiset;
node_ptr node_; node_ptr node_;
public: public:

View File

@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. // 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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. // 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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

View File

@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. // 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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -37,6 +37,8 @@
#endif #endif
namespace boost namespace boost
{
namespace unordered
{ {
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
class unordered_map class unordered_map
@ -93,12 +95,6 @@ namespace boost
table table_; table table_;
BOOST_DEDUCED_TYPENAME types::node_ptr const&
get(const_iterator const& it)
{
return ::boost::unordered::detail::iterator_access::get(it);
}
public: public:
// construct/destroy/copy // construct/destroy/copy
@ -425,12 +421,6 @@ namespace boost
table table_; table table_;
BOOST_DEDUCED_TYPENAME types::node_ptr const&
get(const_iterator const& it)
{
return ::boost::unordered::detail::iterator_access::get(it);
}
public: public:
// construct/destroy/copy // construct/destroy/copy
@ -957,7 +947,7 @@ namespace boost
BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator
unordered_map<K,T,H,P,A>::erase(const_iterator position) unordered_map<K,T,H,P,A>::erase(const_iterator position)
{ {
return iterator(table_.erase(get(position))); return iterator(table_.erase(position.node_));
} }
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@ -972,7 +962,7 @@ namespace boost
unordered_map<K,T,H,P,A>::erase( unordered_map<K,T,H,P,A>::erase(
const_iterator first, const_iterator last) 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 <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@ -1411,7 +1401,7 @@ namespace boost
BOOST_DEDUCED_TYPENAME unordered_multimap<K,T,H,P,A>::iterator BOOST_DEDUCED_TYPENAME unordered_multimap<K,T,H,P,A>::iterator
unordered_multimap<K,T,H,P,A>::erase(const_iterator position) unordered_multimap<K,T,H,P,A>::erase(const_iterator position)
{ {
return iterator(table_.erase(get(position))); return iterator(table_.erase(position.node_));
} }
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@ -1426,7 +1416,7 @@ namespace boost
unordered_multimap<K,T,H,P,A>::erase( unordered_multimap<K,T,H,P,A>::erase(
const_iterator first, const_iterator last) 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 <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@ -1584,7 +1574,7 @@ namespace boost
m1.swap(m2); m1.swap(m2);
} }
} // namespace unordered
} // namespace boost } // namespace boost
#if defined(BOOST_MSVC) #if defined(BOOST_MSVC)

View File

@ -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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -10,44 +10,12 @@
# pragma once # pragma once
#endif #endif
#include <boost/config.hpp> #include <boost/unordered/detail/fwd.hpp>
#include <memory>
#include <functional>
#include <boost/functional/hash_fwd.hpp>
namespace boost namespace boost
{ {
template <class K, using ::boost::unordered::unordered_map;
class T, using ::boost::unordered::unordered_multimap;
class H = hash<K>,
class P = std::equal_to<K>,
class A = std::allocator<std::pair<const K, T> > >
class unordered_map;
template <class K, class T, class H, class P, class A>
inline bool operator==(unordered_map<K, T, H, P, A> const&,
unordered_map<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
inline bool operator!=(unordered_map<K, T, H, P, A> const&,
unordered_map<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
inline void swap(unordered_map<K, T, H, P, A>&,
unordered_map<K, T, H, P, A>&);
template <class K,
class T,
class H = hash<K>,
class P = std::equal_to<K>,
class A = std::allocator<std::pair<const K, T> > >
class unordered_multimap;
template <class K, class T, class H, class P, class A>
inline bool operator==(unordered_multimap<K, T, H, P, A> const&,
unordered_multimap<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
inline bool operator!=(unordered_multimap<K, T, H, P, A> const&,
unordered_multimap<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
inline void swap(unordered_multimap<K, T, H, P, A>&,
unordered_multimap<K, T, H, P, A>&);
} }
#endif #endif

View File

@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard. // 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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -37,6 +37,8 @@
#endif #endif
namespace boost namespace boost
{
namespace unordered
{ {
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
class unordered_set class unordered_set
@ -90,12 +92,6 @@ namespace boost
#endif #endif
table table_; table table_;
BOOST_DEDUCED_TYPENAME types::node_ptr const&
get(const_iterator const& it)
{
return ::boost::unordered::detail::iterator_access::get(it);
}
public: public:
@ -402,12 +398,6 @@ namespace boost
#endif #endif
table table_; table table_;
BOOST_DEDUCED_TYPENAME types::node_ptr const&
get(const_iterator const& it)
{
return ::boost::unordered::detail::iterator_access::get(it);
}
public: public:
@ -919,7 +909,7 @@ namespace boost
BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator
unordered_set<T,H,P,A>::erase(const_iterator position) unordered_set<T,H,P,A>::erase(const_iterator position)
{ {
return iterator(table_.erase(get(position))); return iterator(table_.erase(position.node_));
} }
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
@ -933,7 +923,7 @@ namespace boost
BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator
unordered_set<T,H,P,A>::erase(const_iterator first, const_iterator last) unordered_set<T,H,P,A>::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 <class T, class H, class P, class A> template <class T, class H, class P, class A>
@ -1318,7 +1308,7 @@ namespace boost
BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator
unordered_multiset<T,H,P,A>::erase(const_iterator position) unordered_multiset<T,H,P,A>::erase(const_iterator position)
{ {
return iterator(table_.erase(get(position))); return iterator(table_.erase(position.node_));
} }
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
@ -1332,7 +1322,7 @@ namespace boost
BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator
unordered_multiset<T,H,P,A>::erase(const_iterator first, const_iterator last) unordered_multiset<T,H,P,A>::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 <class T, class H, class P, class A> template <class T, class H, class P, class A>
@ -1461,6 +1451,7 @@ namespace boost
m1.swap(m2); m1.swap(m2);
} }
} // namespace unordered
} // namespace boost } // namespace boost
#if defined(BOOST_MSVC) #if defined(BOOST_MSVC)

View File

@ -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 // 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) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -10,42 +10,12 @@
# pragma once # pragma once
#endif #endif
#include <boost/config.hpp> #include <boost/unordered/detail/fwd.hpp>
#include <memory>
#include <functional>
#include <boost/functional/hash_fwd.hpp>
namespace boost namespace boost
{ {
template <class T, using ::boost::unordered::unordered_set;
class H = hash<T>, using ::boost::unordered::unordered_multiset;
class P = std::equal_to<T>,
class A = std::allocator<T> >
class unordered_set;
template <class T, class H, class P, class A>
inline bool operator==(unordered_set<T, H, P, A> const&,
unordered_set<T, H, P, A> const&);
template <class T, class H, class P, class A>
inline bool operator!=(unordered_set<T, H, P, A> const&,
unordered_set<T, H, P, A> const&);
template <class T, class H, class P, class A>
inline void swap(unordered_set<T, H, P, A> &m1,
unordered_set<T, H, P, A> &m2);
template <class T,
class H = hash<T>,
class P = std::equal_to<T>,
class A = std::allocator<T> >
class unordered_multiset;
template <class T, class H, class P, class A>
inline bool operator==(unordered_multiset<T, H, P, A> const&,
unordered_multiset<T, H, P, A> const&);
template <class T, class H, class P, class A>
inline bool operator!=(unordered_multiset<T, H, P, A> const&,
unordered_multiset<T, H, P, A> const&);
template <class T, class H, class P, class A>
inline void swap(unordered_multiset<T, H, P, A> &m1,
unordered_multiset<T, H, P, A> &m2);
} }
#endif #endif