Since all the compilers support out of line template members use them

and lots of other things.

[SVN r56329]
This commit is contained in:
Daniel James
2009-09-20 21:55:15 +00:00
parent 491fa330f6
commit 78b078f41d
16 changed files with 2462 additions and 2061 deletions

View File

@@ -16,7 +16,8 @@
#include <boost/unordered/unordered_set_fwd.hpp>
#include <boost/functional/hash.hpp>
#include <boost/unordered/detail/allocator_helpers.hpp>
#include <boost/unordered/detail/insert.hpp>
#include <boost/unordered/detail/equivalent.hpp>
#include <boost/unordered/detail/unique.hpp>
#if !defined(BOOST_HAS_RVALUE_REFS)
#include <boost/unordered/detail/move.hpp>
@@ -53,27 +54,34 @@ namespace boost
#endif
typedef BOOST_DEDUCED_TYPENAME
boost::unordered_detail::rebind_wrap<allocator_type, value_type>::type
boost::unordered_detail::rebind_wrap<
allocator_type, value_type>::type
value_allocator;
typedef boost::unordered_detail::hash_unique_table<Hash, Pred, value_allocator,
boost::unordered_detail::set_extractor> table;
typedef boost::unordered_detail::hash_unique_table<Hash, Pred,
value_allocator, boost::unordered_detail::set_extractor> table;
typedef BOOST_DEDUCED_TYPENAME table::iterator_base iterator_base;
public:
typedef BOOST_DEDUCED_TYPENAME value_allocator::pointer pointer;
typedef BOOST_DEDUCED_TYPENAME value_allocator::const_pointer const_pointer;
typedef BOOST_DEDUCED_TYPENAME value_allocator::reference reference;
typedef BOOST_DEDUCED_TYPENAME value_allocator::const_reference const_reference;
typedef BOOST_DEDUCED_TYPENAME
value_allocator::pointer pointer;
typedef BOOST_DEDUCED_TYPENAME
value_allocator::const_pointer const_pointer;
typedef BOOST_DEDUCED_TYPENAME
value_allocator::reference reference;
typedef BOOST_DEDUCED_TYPENAME
value_allocator::const_reference const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef boost::unordered_detail::hash_const_local_iterator<
value_allocator, boost::unordered_detail::ungrouped> const_local_iterator;
value_allocator, boost::unordered_detail::ungrouped>
const_local_iterator;
typedef boost::unordered_detail::hash_const_iterator<
value_allocator, boost::unordered_detail::ungrouped> const_iterator;
value_allocator, boost::unordered_detail::ungrouped>
const_iterator;
typedef const_local_iterator local_iterator;
typedef const_iterator iterator;
@@ -94,47 +102,49 @@ namespace boost
// construct/destroy/copy
explicit unordered_set(
size_type n = boost::unordered_detail::default_initial_bucket_count,
size_type n = boost::unordered_detail::default_bucket_count,
const hasher &hf = hasher(),
const key_equal &eql = key_equal(),
const allocator_type &a = allocator_type())
: table_(n, hf, eql, a)
: table_(n, hf, eql, a)
{
}
explicit unordered_set(allocator_type const& a)
: table_(boost::unordered_detail::default_initial_bucket_count,
: table_(boost::unordered_detail::default_bucket_count,
hasher(), key_equal(), a)
{
}
unordered_set(unordered_set const& other, allocator_type const& a)
: table_(other.table_, a)
: table_(other.table_, a)
{
}
template <class InputIterator>
unordered_set(InputIterator f, InputIterator l)
: table_(boost::unordered_detail::initial_size(f, l), hasher(), key_equal(), allocator_type())
template <class InputIt>
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 <class InputIterator>
unordered_set(InputIterator f, InputIterator l, size_type n,
template <class InputIt>
unordered_set(InputIt f, InputIt l, size_type n,
const hasher &hf = hasher(),
const key_equal &eql = key_equal())
: table_(boost::unordered_detail::initial_size(f, l, n), hf, eql, allocator_type())
: table_(boost::unordered_detail::initial_size(f, l, n),
hf, eql, allocator_type())
{
table_.insert_range(f, l);
}
template <class InputIterator>
unordered_set(InputIterator f, InputIterator l, size_type n,
template <class InputIt>
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_(boost::unordered_detail::initial_size(f, l, n), hf, eql, a)
{
table_.insert_range(f, l);
}
@@ -143,12 +153,12 @@ namespace boost
#if defined(BOOST_HAS_RVALUE_REFS)
unordered_set(unordered_set&& other)
: table_(other.table_, boost::unordered_detail::move_tag())
: table_(other.table_, boost::unordered_detail::move_tag())
{
}
unordered_set(unordered_set&& other, allocator_type const& a)
: table_(other.table_, a, boost::unordered_detail::move_tag())
: table_(other.table_, a, boost::unordered_detail::move_tag())
{
}
@@ -158,8 +168,10 @@ namespace boost
return *this;
}
#else
unordered_set(boost::unordered_detail::move_from<unordered_set<Value, Hash, Pred, Alloc> > other)
: table_(other.source.table_, boost::unordered_detail::move_tag())
unordered_set(boost::unordered_detail::move_from<
unordered_set<Value, Hash, Pred, Alloc>
> other)
: table_(other.source.table_, boost::unordered_detail::move_tag())
{
}
@@ -174,11 +186,13 @@ namespace boost
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
unordered_set(std::initializer_list<value_type> list,
size_type n = boost::unordered_detail::default_initial_bucket_count,
size_type n = boost::unordered_detail::default_bucket_count,
const hasher &hf = hasher(),
const key_equal &eql = key_equal(),
const allocator_type &a = allocator_type())
: table_(boost::unordered_detail::initial_size(list.begin(), list.end(), n), hf, eql, allocator_type())
: table_(boost::unordered_detail::initial_size(
list.begin(), list.end(), n),
hf, eql, allocator_type())
{
table_.insert_range(list.begin(), list.end());
}
@@ -269,35 +283,36 @@ namespace boost
table_.emplace(v));
}
iterator emplace_hint(const_iterator hint, value_type const& v = value_type())
iterator emplace_hint(const_iterator hint,
value_type const& v = value_type())
{
return iterator(table_.emplace_hint(get(hint), v));
}
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template < \
BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
std::pair<iterator, bool> emplace( \
BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
) \
{ \
return boost::unordered_detail::pair_cast<iterator, bool>( \
table_.emplace( \
BOOST_UNORDERED_CALL_PARAMS(z, n) \
)); \
} \
\
template < \
BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
iterator emplace_hint(const_iterator hint, \
BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
) \
{ \
return iterator(table_.emplace_hint(get(hint), \
BOOST_UNORDERED_CALL_PARAMS(z, n) \
)); \
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template < \
BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
std::pair<iterator, bool> emplace( \
BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
) \
{ \
return boost::unordered_detail::pair_cast<iterator, bool>( \
table_.emplace( \
BOOST_UNORDERED_CALL_PARAMS(z, n) \
)); \
} \
\
template < \
BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
iterator emplace_hint(const_iterator hint, \
BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
) \
{ \
return iterator(table_.emplace_hint(get(hint), \
BOOST_UNORDERED_CALL_PARAMS(z, n) \
)); \
}
BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
@@ -318,8 +333,8 @@ namespace boost
return iterator(table_.emplace_hint(get(hint), obj));
}
template <class InputIterator>
void insert(InputIterator first, InputIterator last)
template <class InputIt>
void insert(InputIt first, InputIt last)
{
table_.insert_range(first, last);
}
@@ -376,7 +391,8 @@ namespace boost
std::pair<const_iterator, const_iterator>
equal_range(const key_type& k) const
{
return boost::unordered_detail::pair_cast<const_iterator, const_iterator>(
return boost::unordered_detail::pair_cast<
const_iterator, const_iterator>(
table_.equal_range(k));
}
@@ -384,7 +400,7 @@ namespace boost
size_type bucket_count() const
{
return table_.bucket_count();
return table_.bucket_count_;
}
size_type max_bucket_count() const
@@ -412,14 +428,14 @@ namespace boost
return const_local_iterator(table_.bucket_begin(n));
}
local_iterator end(size_type n)
local_iterator end(size_type)
{
return local_iterator(table_.bucket_end(n));
return local_iterator();
}
const_local_iterator end(size_type n) const
const_local_iterator end(size_type) const
{
return const_local_iterator(table_.bucket_end(n));
return const_local_iterator();
}
const_local_iterator cbegin(size_type n) const
@@ -427,9 +443,9 @@ namespace boost
return const_local_iterator(table_.bucket_begin(n));
}
const_local_iterator cend(size_type n) const
const_local_iterator cend(size_type) const
{
return const_local_iterator(table_.bucket_end(n));
return const_local_iterator();
}
// hash policy
@@ -455,8 +471,10 @@ namespace boost
}
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
friend bool operator==<Value, Hash, Pred, Alloc>(unordered_set const&, unordered_set const&);
friend bool operator!=<Value, Hash, Pred, Alloc>(unordered_set const&, unordered_set const&);
friend bool operator==<Value, Hash, Pred, Alloc>(
unordered_set const&, unordered_set const&);
friend bool operator!=<Value, Hash, Pred, Alloc>(
unordered_set const&, unordered_set const&);
#endif
}; // class template unordered_set
@@ -496,27 +514,34 @@ namespace boost
private:
#endif
typedef BOOST_DEDUCED_TYPENAME
boost::unordered_detail::rebind_wrap<allocator_type, value_type>::type
boost::unordered_detail::rebind_wrap<
allocator_type, value_type>::type
value_allocator;
typedef boost::unordered_detail::hash_equivalent_table<Hash, Pred, value_allocator,
boost::unordered_detail::set_extractor> table;
typedef boost::unordered_detail::hash_equivalent_table<Hash, Pred,
value_allocator, boost::unordered_detail::set_extractor> table;
typedef BOOST_DEDUCED_TYPENAME table::iterator_base iterator_base;
public:
typedef BOOST_DEDUCED_TYPENAME value_allocator::pointer pointer;
typedef BOOST_DEDUCED_TYPENAME value_allocator::const_pointer const_pointer;
typedef BOOST_DEDUCED_TYPENAME value_allocator::reference reference;
typedef BOOST_DEDUCED_TYPENAME value_allocator::const_reference const_reference;
typedef BOOST_DEDUCED_TYPENAME
value_allocator::pointer pointer;
typedef BOOST_DEDUCED_TYPENAME
value_allocator::const_pointer const_pointer;
typedef BOOST_DEDUCED_TYPENAME
value_allocator::reference reference;
typedef BOOST_DEDUCED_TYPENAME
value_allocator::const_reference const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef boost::unordered_detail::hash_const_local_iterator<
value_allocator, boost::unordered_detail::grouped> const_local_iterator;
value_allocator, boost::unordered_detail::grouped>
const_local_iterator;
typedef boost::unordered_detail::hash_const_iterator<
value_allocator, boost::unordered_detail::grouped> const_iterator;
value_allocator, boost::unordered_detail::grouped>
const_iterator;
typedef const_local_iterator local_iterator;
typedef const_iterator iterator;
@@ -537,7 +562,7 @@ namespace boost
// construct/destroy/copy
explicit unordered_multiset(
size_type n = boost::unordered_detail::default_initial_bucket_count,
size_type n = boost::unordered_detail::default_bucket_count,
const hasher &hf = hasher(),
const key_equal &eql = key_equal(),
const allocator_type &a = allocator_type())
@@ -546,34 +571,37 @@ namespace boost
}
explicit unordered_multiset(allocator_type const& a)
: table_(boost::unordered_detail::default_initial_bucket_count,
: table_(boost::unordered_detail::default_bucket_count,
hasher(), key_equal(), a)
{
}
unordered_multiset(unordered_multiset const& other, allocator_type const& a)
: table_(other.table_, a)
unordered_multiset(unordered_multiset const& other,
allocator_type const& a)
: table_(other.table_, a)
{
}
template <class InputIterator>
unordered_multiset(InputIterator f, InputIterator l)
: table_(boost::unordered_detail::initial_size(f, l), hasher(), key_equal(), allocator_type())
template <class InputIt>
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 <class InputIterator>
unordered_multiset(InputIterator f, InputIterator l, size_type n,
template <class InputIt>
unordered_multiset(InputIt f, InputIt l, size_type n,
const hasher &hf = hasher(),
const key_equal &eql = key_equal())
: table_(boost::unordered_detail::initial_size(f, l, n), hf, eql, allocator_type())
: table_(boost::unordered_detail::initial_size(f, l, n),
hf, eql, allocator_type())
{
table_.insert_range(f, l);
}
template <class InputIterator>
unordered_multiset(InputIterator f, InputIterator l, size_type n,
template <class InputIt>
unordered_multiset(InputIt f, InputIt l, size_type n,
const hasher &hf,
const key_equal &eql,
const allocator_type &a)
@@ -586,12 +614,12 @@ namespace boost
#if defined(BOOST_HAS_RVALUE_REFS)
unordered_multiset(unordered_multiset&& other)
: table_(other.table_, boost::unordered_detail::move_tag())
: table_(other.table_, boost::unordered_detail::move_tag())
{
}
unordered_multiset(unordered_multiset&& other, allocator_type const& a)
: table_(other.table_, a, boost::unordered_detail::move_tag())
: table_(other.table_, a, boost::unordered_detail::move_tag())
{
}
@@ -601,8 +629,10 @@ namespace boost
return *this;
}
#else
unordered_multiset(boost::unordered_detail::move_from<unordered_multiset<Value, Hash, Pred, Alloc> > other)
: table_(other.source.table_, boost::unordered_detail::move_tag())
unordered_multiset(boost::unordered_detail::move_from<
unordered_multiset<Value, Hash, Pred, Alloc>
> other)
: table_(other.source.table_, boost::unordered_detail::move_tag())
{
}
@@ -617,11 +647,13 @@ namespace boost
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
unordered_multiset(std::initializer_list<value_type> list,
size_type n = boost::unordered_detail::default_initial_bucket_count,
size_type n = boost::unordered_detail::default_bucket_count,
const hasher &hf = hasher(),
const key_equal &eql = key_equal(),
const allocator_type &a = allocator_type())
: table_(boost::unordered_detail::initial_size(list.begin(), list.end(), n), hf, eql, allocator_type())
: table_(boost::unordered_detail::initial_size(
list.begin(), list.end(), n),
hf, eql, allocator_type())
{
table_.insert_range(list.begin(), list.end());
}
@@ -700,7 +732,8 @@ namespace boost
template <class... Args>
iterator emplace_hint(const_iterator hint, Args&&... args)
{
return iterator(table_.emplace_hint(get(hint), std::forward<Args>(args)...));
return iterator(table_.emplace_hint(get(hint),
std::forward<Args>(args)...));
}
#else
@@ -709,33 +742,34 @@ namespace boost
return iterator(table_.emplace(v));
}
iterator emplace_hint(const_iterator hint, value_type const& v = value_type())
iterator emplace_hint(const_iterator hint,
value_type const& v = value_type())
{
return iterator(table_.emplace_hint(get(hint), v));
}
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template < \
BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
iterator emplace( \
BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
) \
{ \
return iterator( \
table_.emplace(BOOST_UNORDERED_CALL_PARAMS(z, n))); \
} \
\
template < \
BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
iterator emplace_hint(const_iterator hint, \
BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
) \
{ \
return iterator(table_.emplace_hint(get(hint), \
BOOST_UNORDERED_CALL_PARAMS(z, n) \
)); \
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template < \
BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
iterator emplace( \
BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
) \
{ \
return iterator( \
table_.emplace(BOOST_UNORDERED_CALL_PARAMS(z, n))); \
} \
\
template < \
BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
iterator emplace_hint(const_iterator hint, \
BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
) \
{ \
return iterator(table_.emplace_hint(get(hint), \
BOOST_UNORDERED_CALL_PARAMS(z, n) \
)); \
}
BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
@@ -755,8 +789,8 @@ namespace boost
return iterator(table_.emplace_hint(get(hint), obj));
}
template <class InputIterator>
void insert(InputIterator first, InputIterator last)
template <class InputIt>
void insert(InputIt first, InputIt last)
{
table_.insert_range(first, last);
}
@@ -813,7 +847,8 @@ namespace boost
std::pair<const_iterator, const_iterator>
equal_range(const key_type& k) const
{
return boost::unordered_detail::pair_cast<const_iterator, const_iterator>(
return boost::unordered_detail::pair_cast<
const_iterator, const_iterator>(
table_.equal_range(k));
}
@@ -821,7 +856,7 @@ namespace boost
size_type bucket_count() const
{
return table_.bucket_count();
return table_.bucket_count_;
}
size_type max_bucket_count() const
@@ -849,14 +884,14 @@ namespace boost
return const_local_iterator(table_.bucket_begin(n));
}
local_iterator end(size_type n)
local_iterator end(size_type)
{
return local_iterator(table_.bucket_end(n));
return local_iterator();
}
const_local_iterator end(size_type n) const
const_local_iterator end(size_type) const
{
return const_local_iterator(table_.bucket_end(n));
return const_local_iterator();
}
const_local_iterator cbegin(size_type n) const
@@ -864,9 +899,9 @@ namespace boost
return const_local_iterator(table_.bucket_begin(n));
}
const_local_iterator cend(size_type n) const
const_local_iterator cend(size_type) const
{
return const_local_iterator(table_.bucket_end(n));
return const_local_iterator();
}
// hash policy
@@ -892,8 +927,10 @@ namespace boost
}
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
friend bool operator==<Value, Hash, Pred, Alloc>(unordered_multiset const&, unordered_multiset const&);
friend bool operator!=<Value, Hash, Pred, Alloc>(unordered_multiset const&, unordered_multiset const&);
friend bool operator==<Value, Hash, Pred, Alloc>(
unordered_multiset const&, unordered_multiset const&);
friend bool operator!=<Value, Hash, Pred, Alloc>(
unordered_multiset const&, unordered_multiset const&);
#endif
}; // class template unordered_multiset