Get unordered working on Visual C++ 6.5

[SVN r2992]
This commit is contained in:
Daniel James
2006-06-18 13:24:38 +00:00
parent ff91c72eec
commit f9907e4a55
5 changed files with 72 additions and 65 deletions

View File

@ -1677,10 +1677,10 @@ namespace boost {
// if hash function throws, or inserting > 1 element, basic exception safety
// strong otherwise
template <class InputIterator>
void insert(InputIterator i, InputIterator j)
template <class I>
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;
insert_for_range(i, j, iterator_traversal_tag);
}
@ -1789,6 +1789,14 @@ namespace boost {
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
// strong otherwise
template <class InputIterator>
@ -1817,10 +1825,7 @@ namespace boost {
// reserve has basic exception safety if the hash function
// throws, strong otherwise.
if(size() + 1 >= max_load_) {
BOOST_DEDUCED_TYPENAME boost::iterator_traversal<InputIterator>::type
iterator_traversal_tag;
reserve(size() + insert_size(i, j, iterator_traversal_tag));
reserve(size() + insert_size(i, j));
bucket = this->buckets_ + this->index_from_hash(hash_value);
}

View File

@ -11,12 +11,10 @@
#include <vector>
#include <algorithm>
#include "./metafunctions.hpp"
#include "./fwd.hpp"
namespace test
{
struct base_type {} base;
struct derived_type : base_type {} derived;
template <class T1, class T2>
bool equivalent_impl(T1 const& x, T2 const& y, base_type) {
return x == y;

View File

@ -16,6 +16,9 @@ namespace test
float generate(float const*);
template <class T1, class T2>
std::pair<T1, T2> generate(std::pair<T1, T2>*);
struct base_type {} base;
struct derived_type : base_type {} derived;
}
#endif

View File

@ -339,26 +339,21 @@ namespace test
return (std::numeric_limits<size_type>::max)();
}
friend bool operator==(allocator const& x, allocator const& y);
friend bool operator!=(allocator const& x, allocator const& y)
bool operator==(allocator const& x) const
{
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>
bool operator==(test::allocator<T> const& x, test::allocator<T> const& y)
{
return x.tag_ == y.tag_;
bool equivalent_impl(allocator<T> const& x, allocator<T> const& y, test::derived_type) {
return x == y;
}
#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
}
#endif
#endif

View File

@ -20,17 +20,18 @@ template <class T> void sink(T const&) {}
template <class X, class Key>
void unordered_set_test(X& r, Key const& k)
{
BOOST_MPL_ASSERT((boost::is_same<
typename X::value_type,
typename X::key_type>));
typedef typename X::value_type value_type;
typedef typename X::key_type key_type;
BOOST_MPL_ASSERT((boost::is_same<value_type, key_type>));
}
template <class X, class Key, class T>
void unordered_map_test(X& r, Key const& k, T const& t)
{
BOOST_MPL_ASSERT((boost::is_same<
typename X::value_type,
std::pair<const typename X::key_type, T> >));
typedef typename X::value_type value_type;
typedef typename X::key_type key_type;
BOOST_MPL_ASSERT((boost::is_same<value_type, std::pair<key_type const, 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>
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::const_iterator const_iterator;
typedef typename X::local_iterator local_iterator;
typedef typename X::const_local_iterator const_local_iterator;
typedef typename X::key_type key_type;
typedef typename X::hasher hasher;
typedef typename X::key_equal key_equal;
typedef typename boost::BOOST_ITERATOR_CATEGORY<iterator>::type iterator_category;
typedef typename boost::iterator_difference<iterator>::type iterator_difference;
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::function_requires<boost::CopyConstructibleConcept<key_type> >();
@ -72,32 +94,16 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq)
// tests.
boost::function_requires<boost::InputIteratorConcept<local_iterator> >();
BOOST_MPL_ASSERT((boost::is_same<
typename boost::BOOST_ITERATOR_CATEGORY<local_iterator>::type,
typename boost::BOOST_ITERATOR_CATEGORY<iterator>::type >));
BOOST_MPL_ASSERT((boost::is_same<
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_MPL_ASSERT((boost::is_same<local_iterator_category, iterator_category>));
BOOST_MPL_ASSERT((boost::is_same<local_iterator_difference, iterator_difference>));
BOOST_MPL_ASSERT((boost::is_same<local_iterator_pointer, iterator_pointer>));
BOOST_MPL_ASSERT((boost::is_same<local_iterator_reference, iterator_reference>));
boost::function_requires<boost::InputIteratorConcept<const_local_iterator> >();
BOOST_MPL_ASSERT((boost::is_same<
typename boost::BOOST_ITERATOR_CATEGORY<const_local_iterator>::type,
typename boost::BOOST_ITERATOR_CATEGORY<const_iterator>::type >));
BOOST_MPL_ASSERT((boost::is_same<
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 >));
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_category, const_iterator_category>));
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_difference, const_iterator_difference>));
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_pointer, const_iterator_pointer>));
BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_reference, const_iterator_reference>));
X(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?
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());
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<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(
a.equal_range(k));
test::check_return_type<std::pair<const_iterator, const_iterator> >::equals(
b.equal_range(k));
test::check_return_type<typename X::size_type>::equals(b.bucket_count());
test::check_return_type<typename X::size_type>::equals(b.max_bucket_count());
test::check_return_type<typename X::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_count());
test::check_return_type<size_type>::equals(b.max_bucket_count());
test::check_return_type<size_type>::equals(b.bucket(k));
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<const_local_iterator>::equals(b.begin(0));