mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 20:04:29 +02:00
Get unordered working on Visual C++ 6.5
[SVN r2992]
This commit is contained in:
@@ -1677,10 +1677,10 @@ namespace boost {
|
|||||||
|
|
||||||
// if hash function throws, or inserting > 1 element, basic exception safety
|
// if hash function throws, or inserting > 1 element, basic exception safety
|
||||||
// strong otherwise
|
// strong otherwise
|
||||||
template <class InputIterator>
|
template <class I>
|
||||||
void insert(InputIterator i, InputIterator j)
|
void insert(I i, I j)
|
||||||
{
|
{
|
||||||
BOOST_DEDUCED_TYPENAME boost::iterator_traversal<InputIterator>::type
|
BOOST_DEDUCED_TYPENAME boost::iterator_traversal<I>::type
|
||||||
iterator_traversal_tag;
|
iterator_traversal_tag;
|
||||||
insert_for_range(i, j, iterator_traversal_tag);
|
insert_for_range(i, j, iterator_traversal_tag);
|
||||||
}
|
}
|
||||||
@@ -1789,6 +1789,14 @@ namespace boost {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class I>
|
||||||
|
std::size_t insert_size(I i, I j)
|
||||||
|
{
|
||||||
|
BOOST_DEDUCED_TYPENAME boost::iterator_traversal<I>::type
|
||||||
|
iterator_traversal_tag;
|
||||||
|
return insert_size(i, j, iterator_traversal_tag);
|
||||||
|
};
|
||||||
|
|
||||||
// if hash function throws, or inserting > 1 element, basic exception safety
|
// if hash function throws, or inserting > 1 element, basic exception safety
|
||||||
// strong otherwise
|
// strong otherwise
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
@@ -1817,10 +1825,7 @@ namespace boost {
|
|||||||
// reserve has basic exception safety if the hash function
|
// reserve has basic exception safety if the hash function
|
||||||
// throws, strong otherwise.
|
// throws, strong otherwise.
|
||||||
if(size() + 1 >= max_load_) {
|
if(size() + 1 >= max_load_) {
|
||||||
BOOST_DEDUCED_TYPENAME boost::iterator_traversal<InputIterator>::type
|
reserve(size() + insert_size(i, j));
|
||||||
iterator_traversal_tag;
|
|
||||||
|
|
||||||
reserve(size() + insert_size(i, j, iterator_traversal_tag));
|
|
||||||
bucket = this->buckets_ + this->index_from_hash(hash_value);
|
bucket = this->buckets_ + this->index_from_hash(hash_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,12 +11,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "./metafunctions.hpp"
|
#include "./metafunctions.hpp"
|
||||||
|
#include "./fwd.hpp"
|
||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
struct base_type {} base;
|
|
||||||
struct derived_type : base_type {} derived;
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
bool equivalent_impl(T1 const& x, T2 const& y, base_type) {
|
bool equivalent_impl(T1 const& x, T2 const& y, base_type) {
|
||||||
return x == y;
|
return x == y;
|
||||||
|
@@ -16,6 +16,9 @@ namespace test
|
|||||||
float generate(float const*);
|
float generate(float const*);
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
std::pair<T1, T2> generate(std::pair<T1, T2>*);
|
std::pair<T1, T2> generate(std::pair<T1, T2>*);
|
||||||
|
|
||||||
|
struct base_type {} base;
|
||||||
|
struct derived_type : base_type {} derived;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -339,26 +339,21 @@ namespace test
|
|||||||
return (std::numeric_limits<size_type>::max)();
|
return (std::numeric_limits<size_type>::max)();
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(allocator const& x, allocator const& y);
|
bool operator==(allocator const& x) const
|
||||||
|
|
||||||
friend bool operator!=(allocator const& x, allocator const& y)
|
|
||||||
{
|
{
|
||||||
return x.tag_ != y.tag_;
|
return tag_ == x.tag_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(allocator const& x) const
|
||||||
|
{
|
||||||
|
return tag_ != x.tag_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
|
||||||
namespace test
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool operator==(test::allocator<T> const& x, test::allocator<T> const& y)
|
bool equivalent_impl(allocator<T> const& x, allocator<T> const& y, test::derived_type) {
|
||||||
{
|
return x == y;
|
||||||
return x.tag_ == y.tag_;
|
|
||||||
}
|
}
|
||||||
#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -20,17 +20,18 @@ template <class T> void sink(T const&) {}
|
|||||||
template <class X, class Key>
|
template <class X, class Key>
|
||||||
void unordered_set_test(X& r, Key const& k)
|
void unordered_set_test(X& r, Key const& k)
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
typedef typename X::value_type value_type;
|
||||||
typename X::value_type,
|
typedef typename X::key_type key_type;
|
||||||
typename X::key_type>));
|
|
||||||
|
BOOST_MPL_ASSERT((boost::is_same<value_type, key_type>));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class X, class Key, class T>
|
template <class X, class Key, class T>
|
||||||
void unordered_map_test(X& r, Key const& k, T const& t)
|
void unordered_map_test(X& r, Key const& k, T const& t)
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
typedef typename X::value_type value_type;
|
||||||
typename X::value_type,
|
typedef typename X::key_type key_type;
|
||||||
std::pair<const typename X::key_type, T> >));
|
BOOST_MPL_ASSERT((boost::is_same<value_type, std::pair<key_type const, T> >));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class X, class T>
|
template <class X, class T>
|
||||||
@@ -50,14 +51,35 @@ void unordered_equivalent_test(X& r, T const& t)
|
|||||||
template <class X, class Key, class T, class Hash, class Pred>
|
template <class X, class Key, class T, class Hash, class Pred>
|
||||||
void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq)
|
void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq)
|
||||||
{
|
{
|
||||||
|
typedef typename X::key_type key_type;
|
||||||
|
typedef typename X::hasher hasher;
|
||||||
|
typedef typename X::key_equal key_equal;
|
||||||
|
typedef typename X::size_type size_type;
|
||||||
|
|
||||||
typedef typename X::iterator iterator;
|
typedef typename X::iterator iterator;
|
||||||
typedef typename X::const_iterator const_iterator;
|
typedef typename X::const_iterator const_iterator;
|
||||||
typedef typename X::local_iterator local_iterator;
|
typedef typename X::local_iterator local_iterator;
|
||||||
typedef typename X::const_local_iterator const_local_iterator;
|
typedef typename X::const_local_iterator const_local_iterator;
|
||||||
|
|
||||||
typedef typename X::key_type key_type;
|
typedef typename boost::BOOST_ITERATOR_CATEGORY<iterator>::type iterator_category;
|
||||||
typedef typename X::hasher hasher;
|
typedef typename boost::iterator_difference<iterator>::type iterator_difference;
|
||||||
typedef typename X::key_equal key_equal;
|
typedef typename boost::iterator_pointer<iterator>::type iterator_pointer;
|
||||||
|
typedef typename boost::iterator_reference<iterator>::type iterator_reference;
|
||||||
|
|
||||||
|
typedef typename boost::BOOST_ITERATOR_CATEGORY<local_iterator>::type local_iterator_category;
|
||||||
|
typedef typename boost::iterator_difference<local_iterator>::type local_iterator_difference;
|
||||||
|
typedef typename boost::iterator_pointer<local_iterator>::type local_iterator_pointer;
|
||||||
|
typedef typename boost::iterator_reference<local_iterator>::type local_iterator_reference;
|
||||||
|
|
||||||
|
typedef typename boost::BOOST_ITERATOR_CATEGORY<const_iterator>::type const_iterator_category;
|
||||||
|
typedef typename boost::iterator_difference<const_iterator>::type const_iterator_difference;
|
||||||
|
typedef typename boost::iterator_pointer<const_iterator>::type const_iterator_pointer;
|
||||||
|
typedef typename boost::iterator_reference<const_iterator>::type const_iterator_reference;
|
||||||
|
|
||||||
|
typedef typename boost::BOOST_ITERATOR_CATEGORY<const_local_iterator>::type const_local_iterator_category;
|
||||||
|
typedef typename boost::iterator_difference<const_local_iterator>::type const_local_iterator_difference;
|
||||||
|
typedef typename boost::iterator_pointer<const_local_iterator>::type const_local_iterator_pointer;
|
||||||
|
typedef typename boost::iterator_reference<const_local_iterator>::type const_local_iterator_reference;
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<Key, key_type>));
|
BOOST_MPL_ASSERT((boost::is_same<Key, key_type>));
|
||||||
boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
|
boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
|
||||||
@@ -72,32 +94,16 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq)
|
|||||||
// tests.
|
// tests.
|
||||||
|
|
||||||
boost::function_requires<boost::InputIteratorConcept<local_iterator> >();
|
boost::function_requires<boost::InputIteratorConcept<local_iterator> >();
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
BOOST_MPL_ASSERT((boost::is_same<local_iterator_category, iterator_category>));
|
||||||
typename boost::BOOST_ITERATOR_CATEGORY<local_iterator>::type,
|
BOOST_MPL_ASSERT((boost::is_same<local_iterator_difference, iterator_difference>));
|
||||||
typename boost::BOOST_ITERATOR_CATEGORY<iterator>::type >));
|
BOOST_MPL_ASSERT((boost::is_same<local_iterator_pointer, iterator_pointer>));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
BOOST_MPL_ASSERT((boost::is_same<local_iterator_reference, iterator_reference>));
|
||||||
typename boost::iterator_difference<local_iterator>::type,
|
|
||||||
typename boost::iterator_difference<iterator>::type >));
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
|
||||||
typename boost::iterator_pointer<local_iterator>::type,
|
|
||||||
typename boost::iterator_pointer<iterator>::type >));
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
|
||||||
typename boost::iterator_reference<local_iterator>::type,
|
|
||||||
typename boost::iterator_reference<iterator>::type >));
|
|
||||||
|
|
||||||
boost::function_requires<boost::InputIteratorConcept<const_local_iterator> >();
|
boost::function_requires<boost::InputIteratorConcept<const_local_iterator> >();
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_category, const_iterator_category>));
|
||||||
typename boost::BOOST_ITERATOR_CATEGORY<const_local_iterator>::type,
|
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_difference, const_iterator_difference>));
|
||||||
typename boost::BOOST_ITERATOR_CATEGORY<const_iterator>::type >));
|
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_pointer, const_iterator_pointer>));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_reference, const_iterator_reference>));
|
||||||
typename boost::iterator_difference<const_local_iterator>::type,
|
|
||||||
typename boost::iterator_difference<const_iterator>::type >));
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
|
||||||
typename boost::iterator_pointer<const_local_iterator>::type,
|
|
||||||
typename boost::iterator_pointer<const_iterator>::type >));
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<
|
|
||||||
typename boost::iterator_reference<const_local_iterator>::type,
|
|
||||||
typename boost::iterator_reference<const_iterator>::type >));
|
|
||||||
|
|
||||||
X(10, hf, eq);
|
X(10, hf, eq);
|
||||||
X a(10, hf, eq);
|
X a(10, hf, eq);
|
||||||
@@ -135,7 +141,7 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq)
|
|||||||
|
|
||||||
// TODO: void return?
|
// TODO: void return?
|
||||||
a.insert(i, j);
|
a.insert(i, j);
|
||||||
test::check_return_type<typename X::size_type>::equals(a.erase(k));
|
test::check_return_type<size_type>::equals(a.erase(k));
|
||||||
|
|
||||||
BOOST_TEST(a.empty());
|
BOOST_TEST(a.empty());
|
||||||
if(a.empty()) {
|
if(a.empty()) {
|
||||||
@@ -162,15 +168,15 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq)
|
|||||||
|
|
||||||
test::check_return_type<iterator>::equals(a.find(k));
|
test::check_return_type<iterator>::equals(a.find(k));
|
||||||
test::check_return_type<const_iterator>::equals(b.find(k));
|
test::check_return_type<const_iterator>::equals(b.find(k));
|
||||||
test::check_return_type<typename X::size_type>::equals(b.count(k));
|
test::check_return_type<size_type>::equals(b.count(k));
|
||||||
test::check_return_type<std::pair<iterator, iterator> >::equals(
|
test::check_return_type<std::pair<iterator, iterator> >::equals(
|
||||||
a.equal_range(k));
|
a.equal_range(k));
|
||||||
test::check_return_type<std::pair<const_iterator, const_iterator> >::equals(
|
test::check_return_type<std::pair<const_iterator, const_iterator> >::equals(
|
||||||
b.equal_range(k));
|
b.equal_range(k));
|
||||||
test::check_return_type<typename X::size_type>::equals(b.bucket_count());
|
test::check_return_type<size_type>::equals(b.bucket_count());
|
||||||
test::check_return_type<typename X::size_type>::equals(b.max_bucket_count());
|
test::check_return_type<size_type>::equals(b.max_bucket_count());
|
||||||
test::check_return_type<typename X::size_type>::equals(b.bucket(k));
|
test::check_return_type<size_type>::equals(b.bucket(k));
|
||||||
test::check_return_type<typename X::size_type>::equals(b.bucket_size(0));
|
test::check_return_type<size_type>::equals(b.bucket_size(0));
|
||||||
|
|
||||||
test::check_return_type<local_iterator>::equals(a.begin(0));
|
test::check_return_type<local_iterator>::equals(a.begin(0));
|
||||||
test::check_return_type<const_local_iterator>::equals(b.begin(0));
|
test::check_return_type<const_local_iterator>::equals(b.begin(0));
|
||||||
|
Reference in New Issue
Block a user