[DEV] add v1.76.0

This commit is contained in:
2021-10-05 21:37:46 +02:00
parent a97e9ae7d4
commit d0115b733d
45133 changed files with 4744437 additions and 1026325 deletions

View File

@@ -3,7 +3,7 @@
// 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)
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
@@ -36,8 +36,8 @@
{ \
return (std::numeric_limits<std::size_t>::max)(); \
} \
bool operator==(name<T> const&) { return true; } \
bool operator!=(name<T> const&) { return false; } \
bool operator==(name<T> const&) const { return true; } \
bool operator!=(name<T> const&) const { return false; } \
/**/
#define ALLOCATOR_METHODS_TYPEDEFS(name) \
@@ -126,6 +126,7 @@ void test_empty_allocator()
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
BOOST_TEST(!traits::propagate_on_container_swap::value);
BOOST_TEST(traits::is_always_equal::value);
BOOST_TEST(call_select<allocator>() == 0);
}
@@ -139,6 +140,7 @@ template <typename T> struct allocator1
typedef yes_type propagate_on_container_copy_assignment;
typedef yes_type propagate_on_container_move_assignment;
typedef yes_type propagate_on_container_swap;
typedef yes_type is_always_equal;
allocator1<T> select_on_container_copy_construction() const
{
@@ -166,6 +168,7 @@ void test_allocator1()
BOOST_TEST(traits::propagate_on_container_copy_assignment::value);
BOOST_TEST(traits::propagate_on_container_move_assignment::value);
BOOST_TEST(traits::propagate_on_container_swap::value);
BOOST_TEST(traits::is_always_equal::value);
BOOST_TEST(call_select<allocator>() == 1);
}
@@ -192,6 +195,7 @@ template <typename T> struct allocator2 : allocator2_base<allocator2<T> >
typedef no_type propagate_on_container_copy_assignment;
typedef no_type propagate_on_container_move_assignment;
typedef no_type propagate_on_container_swap;
typedef no_type is_always_equal;
};
void test_allocator2()
@@ -208,6 +212,7 @@ void test_allocator2()
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
BOOST_TEST(!traits::propagate_on_container_swap::value);
BOOST_TEST(!traits::is_always_equal::value);
BOOST_TEST(call_select<allocator>() == 1);
}
@@ -240,6 +245,8 @@ template <typename T> struct allocator3
typedef ptr<T const> const_pointer;
typedef unsigned short size_type;
int x; // Just to make it non-empty, so that is_always_equal is false.
ALLOCATOR_METHODS_TYPEDEFS(allocator3)
typedef yes_type propagate_on_container_copy_assignment;
@@ -267,6 +274,7 @@ void test_allocator3()
BOOST_TEST(traits::propagate_on_container_copy_assignment::value);
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
BOOST_TEST(!traits::propagate_on_container_swap::value);
BOOST_TEST(!traits::is_always_equal::value);
BOOST_TEST(call_select<allocator>() == 1);
}

View File

@@ -27,8 +27,8 @@ namespace assign_tests {
template <class T> void assign_tests1(T*, test::random_generator generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::key_equal eq;
typename T::hasher hf;
typename T::key_equal eq;
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "assign_tests1.1\n";
{
@@ -68,14 +68,14 @@ namespace assign_tests {
template <class T> void assign_tests2(T*, test::random_generator generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
BOOST_DEDUCED_TYPENAME T::hasher hf2(2);
BOOST_DEDUCED_TYPENAME T::key_equal eq1(1);
BOOST_DEDUCED_TYPENAME T::key_equal eq2(2);
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
typename T::hasher hf1(1);
typename T::hasher hf2(2);
typename T::key_equal eq1(1);
typename T::key_equal eq2(2);
typename T::allocator_type al1(1);
typename T::allocator_type al2(2);
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
typedef typename T::allocator_type allocator_type;
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "assign_tests2.0 - empty container\n";
{

View File

@@ -25,13 +25,13 @@ namespace at_tests {
try {
x.at("one");
BOOST_ERROR("Should have thrown.");
} catch (std::out_of_range) {
} catch (std::out_of_range&) {
}
try {
x_const.at("one");
BOOST_ERROR("Should have thrown.");
} catch (std::out_of_range) {
} catch (std::out_of_range&) {
}
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Add elements" << std::endl;
@@ -51,13 +51,13 @@ namespace at_tests {
try {
x.at("three");
BOOST_ERROR("Should have thrown.");
} catch (std::out_of_range) {
} catch (std::out_of_range&) {
}
try {
x_const.at("three");
BOOST_ERROR("Should have thrown.");
} catch (std::out_of_range) {
} catch (std::out_of_range&) {
}
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Finished" << std::endl;

View File

@@ -29,8 +29,8 @@ namespace bucket_tests {
{
test::check_instances check_;
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
typedef typename X::size_type size_type;
typedef typename X::const_local_iterator const_local_iterator;
test::random_values<X> v(1000, generator);
X x(v.begin(), v.end());
@@ -41,9 +41,8 @@ namespace bucket_tests {
<< "<=" << x.max_bucket_count() << "\n";
}
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
it = v.begin(),
end = v.end();
for (typename test::random_values<X>::const_iterator it = v.begin(),
end = v.end();
it != end; ++it) {
size_type bucket = x.bucket(test::get_key<X>(*it));

View File

@@ -17,11 +17,12 @@
#endif
#include "../helpers/check_return_type.hpp"
#include <boost/iterator/iterator_traits.hpp>
#include <boost/core/pointer_traits.hpp>
#include <boost/limits.hpp>
#include <boost/predef.h>
#include <boost/static_assert.hpp>
#include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/swap.hpp>
@@ -51,27 +52,27 @@ template <class T> int implicit_construct()
template <class X, class T> void container_test(X& r, T const&)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::difference_type difference_type;
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
typedef typename X::iterator iterator;
typedef typename X::const_iterator const_iterator;
typedef typename X::difference_type difference_type;
typedef typename X::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<iterator>::type
iterator_value_type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<const_iterator>::type
typedef
typename std::iterator_traits<iterator>::value_type iterator_value_type;
typedef typename std::iterator_traits<const_iterator>::value_type
const_iterator_value_type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type
typedef typename std::iterator_traits<iterator>::difference_type
iterator_difference_type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<
const_iterator>::type const_iterator_difference_type;
typedef typename std::iterator_traits<const_iterator>::difference_type
const_iterator_difference_type;
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME X::reference reference;
typedef BOOST_DEDUCED_TYPENAME X::const_reference const_reference;
typedef typename X::value_type value_type;
typedef typename X::reference reference;
typedef typename X::const_reference const_reference;
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
typedef typename X::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
typedef typename X::allocator_type allocator_type;
// value_type
@@ -96,8 +97,8 @@ template <class X, class T> void container_test(X& r, T const&)
// node_type
BOOST_STATIC_ASSERT((boost::is_same<allocator_type,
BOOST_DEDUCED_TYPENAME node_type::allocator_type>::value));
BOOST_STATIC_ASSERT((
boost::is_same<allocator_type, typename node_type::allocator_type>::value));
// difference_type
@@ -207,9 +208,9 @@ template <class X, class T> void container_test(X& r, T const&)
template <class X> void unordered_destructible_test(X&)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
typedef typename X::iterator iterator;
typedef typename X::const_iterator const_iterator;
typedef typename X::size_type size_type;
X x1;
@@ -246,31 +247,30 @@ template <class X> void unordered_destructible_test(X&)
// Allocator
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
typedef typename X::allocator_type allocator_type;
test::check_return_type<allocator_type>::equals(a_const.get_allocator());
}
template <class X, class Key> void unordered_set_test(X& r, Key const&)
{
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
typedef typename X::value_type value_type;
typedef typename X::key_type key_type;
BOOST_STATIC_ASSERT((boost::is_same<value_type, key_type>::value));
// iterator pointer / const_pointer_type
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type
iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::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 std::iterator_traits<iterator>::pointer iterator_pointer;
typedef typename std::iterator_traits<const_iterator>::pointer
const_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type
typedef typename std::iterator_traits<local_iterator>::pointer
local_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<
const_local_iterator>::type const_local_iterator_pointer;
typedef typename std::iterator_traits<const_local_iterator>::pointer
const_local_iterator_pointer;
BOOST_STATIC_ASSERT(
(boost::is_same<value_type const*, iterator_pointer>::value));
@@ -281,8 +281,46 @@ template <class X, class Key> void unordered_set_test(X& r, Key const&)
BOOST_STATIC_ASSERT(
(boost::is_same<value_type const*, const_local_iterator_pointer>::value));
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME node_type::value_type node_value_type;
// pointer_traits<iterator>
BOOST_STATIC_ASSERT((boost::is_same<iterator,
typename boost::pointer_traits<iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
typename boost::pointer_traits<iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
typename boost::pointer_traits<iterator>::difference_type>::value));
// pointer_traits<const_iterator>
BOOST_STATIC_ASSERT((boost::is_same<const_iterator,
typename boost::pointer_traits<const_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
typename boost::pointer_traits<const_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
typename boost::pointer_traits<const_iterator>::difference_type>::value));
// pointer_traits<local_iterator>
BOOST_STATIC_ASSERT((boost::is_same<local_iterator,
typename boost::pointer_traits<local_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
typename boost::pointer_traits<local_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
typename boost::pointer_traits<local_iterator>::difference_type>::value));
// pointer_traits<const_local_iterator>
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator,
typename boost::pointer_traits<const_local_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
typename boost::pointer_traits<const_local_iterator>::element_type>::
value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
typename boost::pointer_traits<const_local_iterator>::difference_type>::
value));
typedef typename X::node_type node_type;
typedef typename node_type::value_type node_value_type;
BOOST_STATIC_ASSERT((boost::is_same<value_type, node_value_type>::value));
// Call node_type functions.
@@ -297,26 +335,25 @@ template <class X, class Key> void unordered_set_test(X& r, Key const&)
template <class X, class Key, class T>
void unordered_map_test(X& r, Key const& k, T const& v)
{
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
typedef typename X::value_type value_type;
typedef typename X::key_type key_type;
BOOST_STATIC_ASSERT(
(boost::is_same<value_type, std::pair<key_type const, T> >::value));
// iterator pointer / const_pointer_type
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type
iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::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 std::iterator_traits<iterator>::pointer iterator_pointer;
typedef typename std::iterator_traits<const_iterator>::pointer
const_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type
typedef typename std::iterator_traits<local_iterator>::pointer
local_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<
const_local_iterator>::type const_local_iterator_pointer;
typedef typename std::iterator_traits<const_local_iterator>::pointer
const_local_iterator_pointer;
BOOST_STATIC_ASSERT((boost::is_same<value_type*, iterator_pointer>::value));
BOOST_STATIC_ASSERT(
@@ -326,9 +363,47 @@ void unordered_map_test(X& r, Key const& k, T const& v)
BOOST_STATIC_ASSERT(
(boost::is_same<value_type const*, const_local_iterator_pointer>::value));
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME node_type::key_type node_key_type;
typedef BOOST_DEDUCED_TYPENAME node_type::mapped_type node_mapped_type;
// pointer_traits<iterator>
BOOST_STATIC_ASSERT((boost::is_same<iterator,
typename boost::pointer_traits<iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type,
typename boost::pointer_traits<iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
typename boost::pointer_traits<iterator>::difference_type>::value));
// pointer_traits<const_iterator>
BOOST_STATIC_ASSERT((boost::is_same<const_iterator,
typename boost::pointer_traits<const_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
typename boost::pointer_traits<const_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
typename boost::pointer_traits<const_iterator>::difference_type>::value));
// pointer_traits<local_iterator>
BOOST_STATIC_ASSERT((boost::is_same<local_iterator,
typename boost::pointer_traits<local_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type,
typename boost::pointer_traits<local_iterator>::element_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
typename boost::pointer_traits<local_iterator>::difference_type>::value));
// pointer_traits<const_local_iterator>
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator,
typename boost::pointer_traits<const_local_iterator>::pointer>::value));
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
typename boost::pointer_traits<const_local_iterator>::element_type>::
value));
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
typename boost::pointer_traits<const_local_iterator>::difference_type>::
value));
typedef typename X::node_type node_type;
typedef typename node_type::key_type node_key_type;
typedef typename node_type::mapped_type node_mapped_type;
BOOST_STATIC_ASSERT((boost::is_same<Key, node_key_type>::value));
BOOST_STATIC_ASSERT((boost::is_same<T, node_mapped_type>::value));
@@ -400,12 +475,12 @@ template <class X> void equality_test(X& r)
template <class X, class T> void unordered_unique_test(X& r, T const& t)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
test::check_return_type<std::pair<iterator, bool> >::equals(r.insert(t));
test::check_return_type<std::pair<iterator, bool> >::equals(r.emplace(t));
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME X::insert_return_type insert_return_type;
typedef typename X::node_type node_type;
typedef typename X::insert_return_type insert_return_type;
// insert_return_type
@@ -432,7 +507,7 @@ template <class X, class T> void unordered_unique_test(X& r, T const& t)
template <class X, class T> void unordered_equivalent_test(X& r, T const& t)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
test::check_return_type<iterator>::equals(r.insert(t));
test::check_return_type<iterator>::equals(r.emplace(t));
}
@@ -440,8 +515,8 @@ template <class X, class T> void unordered_equivalent_test(X& r, T const& t)
template <class X, class Key, class T>
void unordered_map_functions(X&, Key const& k, T const& v)
{
typedef BOOST_DEDUCED_TYPENAME X::mapped_type mapped_type;
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::mapped_type mapped_type;
typedef typename X::iterator iterator;
X a;
test::check_return_type<mapped_type>::equals_ref(a[k]);
@@ -472,52 +547,50 @@ void unordered_test(X& x, Key& k, Hash& hf, Pred& eq)
{
unordered_destructible_test(x);
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
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 BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
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 BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<iterator>::type
typedef typename std::iterator_traits<iterator>::iterator_category
iterator_category;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type
typedef typename std::iterator_traits<iterator>::difference_type
iterator_difference;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type
iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<iterator>::type
iterator_reference;
typedef typename std::iterator_traits<iterator>::pointer iterator_pointer;
typedef typename std::iterator_traits<iterator>::reference iterator_reference;
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<
local_iterator>::type local_iterator_category;
typedef BOOST_DEDUCED_TYPENAME
boost::iterator_difference<local_iterator>::type local_iterator_difference;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type
typedef typename std::iterator_traits<local_iterator>::iterator_category
local_iterator_category;
typedef typename std::iterator_traits<local_iterator>::difference_type
local_iterator_difference;
typedef typename std::iterator_traits<local_iterator>::pointer
local_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<local_iterator>::type
typedef typename std::iterator_traits<local_iterator>::reference
local_iterator_reference;
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<
const_iterator>::type const_iterator_category;
typedef BOOST_DEDUCED_TYPENAME
boost::iterator_difference<const_iterator>::type const_iterator_difference;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::type
typedef typename std::iterator_traits<const_iterator>::iterator_category
const_iterator_category;
typedef typename std::iterator_traits<const_iterator>::difference_type
const_iterator_difference;
typedef typename std::iterator_traits<const_iterator>::pointer
const_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_iterator>::type
typedef typename std::iterator_traits<const_iterator>::reference
const_iterator_reference;
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<
const_local_iterator>::type const_local_iterator_category;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<
const_local_iterator>::type const_local_iterator_difference;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<
const_local_iterator>::type const_local_iterator_pointer;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<
const_local_iterator>::type const_local_iterator_reference;
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
typedef typename std::iterator_traits<const_local_iterator>::iterator_category
const_local_iterator_category;
typedef typename std::iterator_traits<const_local_iterator>::difference_type
const_local_iterator_difference;
typedef typename std::iterator_traits<const_local_iterator>::pointer
const_local_iterator_pointer;
typedef typename std::iterator_traits<const_local_iterator>::reference
const_local_iterator_reference;
typedef typename X::allocator_type allocator_type;
BOOST_STATIC_ASSERT((boost::is_same<Key, key_type>::value));
// boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
@@ -636,15 +709,15 @@ void unordered_copyable_test(X& x, Key& k, T& t, Hash& hf, Pred& eq)
{
unordered_test(x, k, hf, eq);
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
typedef typename X::iterator iterator;
typedef typename X::const_iterator const_iterator;
typedef typename X::allocator_type allocator_type;
X a;
allocator_type m = a.get_allocator();
BOOST_DEDUCED_TYPENAME X::value_type* i = 0;
BOOST_DEDUCED_TYPENAME X::value_type* j = 0;
typename X::value_type* i = 0;
typename X::value_type* j = 0;
// Constructors
@@ -734,8 +807,8 @@ void unordered_copyable_test(X& x, Key& k, T& t, Hash& hf, Pred& eq)
sink(a7a);
sink(a9a);
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
typedef typename X::node_type node_type;
typedef typename X::allocator_type allocator_type;
node_type const n_const = a.extract(a.begin());
test::check_return_type<allocator_type>::equals(n_const.get_allocator());
}
@@ -745,9 +818,9 @@ void unordered_movable_test(X& x, Key& k, T& /* t */, Hash& hf, Pred& eq)
{
unordered_test(x, k, hf, eq);
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
typedef typename X::iterator iterator;
typedef typename X::const_iterator const_iterator;
typedef typename X::allocator_type allocator_type;
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
X x1(rvalue_default<X>());

View File

@@ -25,9 +25,9 @@ namespace constructor_tests {
template <class T>
void constructor_tests1(T*, test::random_generator generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::key_equal eq;
BOOST_DEDUCED_TYPENAME T::allocator_type al;
typename T::hasher hf;
typename T::key_equal eq;
typename T::allocator_type al;
UNORDERED_SUB_TEST("Construct 1")
{
@@ -176,15 +176,15 @@ namespace constructor_tests {
template <class T>
void constructor_tests2(T*, test::random_generator const& generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
BOOST_DEDUCED_TYPENAME T::hasher hf2(2);
BOOST_DEDUCED_TYPENAME T::key_equal eq;
BOOST_DEDUCED_TYPENAME T::key_equal eq1(1);
BOOST_DEDUCED_TYPENAME T::key_equal eq2(2);
BOOST_DEDUCED_TYPENAME T::allocator_type al;
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
typename T::hasher hf;
typename T::hasher hf1(1);
typename T::hasher hf2(2);
typename T::key_equal eq;
typename T::key_equal eq1(1);
typename T::key_equal eq2(2);
typename T::allocator_type al;
typename T::allocator_type al1(1);
typename T::allocator_type al2(2);
UNORDERED_SUB_TEST("Construct 1")
{
@@ -274,14 +274,11 @@ namespace constructor_tests {
{
test::check_instances check_;
test::random_values<T> v(100, generator);
BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator v_begin =
v.begin(),
v_end =
v.end();
typename test::random_values<T>::const_iterator v_begin = v.begin(),
v_end = v.end();
T x(test::input_iterator(v_begin), test::input_iterator(v_end), 0, hf1,
eq1);
BOOST_DEDUCED_TYPENAME T::const_iterator x_begin = x.begin(),
x_end = x.end();
typename T::const_iterator x_begin = x.begin(), x_end = x.end();
T y(test::input_iterator(x_begin), test::input_iterator(x_end), 0, hf2,
eq2);
test::check_container(x, v);
@@ -320,7 +317,7 @@ namespace constructor_tests {
}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
std::initializer_list<BOOST_DEDUCED_TYPENAME T::value_type> list;
std::initializer_list<typename T::value_type> list;
UNORDERED_SUB_TEST("Initializer list construct 1")
{
@@ -386,8 +383,8 @@ namespace constructor_tests {
template <class T>
void map_constructor_test(T*, test::random_generator const& generator)
{
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME T::key_type,
BOOST_DEDUCED_TYPENAME T::mapped_type> >
typedef test::list<
std::pair<typename T::key_type, typename T::mapped_type> >
list;
test::random_values<T> v(1000, generator);
list l(v.begin(), v.end());

View File

@@ -25,11 +25,11 @@ namespace copy_tests {
template <class T>
void copy_construct_tests1(T*, test::random_generator const& generator)
{
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
typedef typename T::allocator_type allocator_type;
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::key_equal eq;
BOOST_DEDUCED_TYPENAME T::allocator_type al;
typename T::hasher hf;
typename T::key_equal eq;
typename T::allocator_type al;
{
test::check_instances check_;
@@ -84,12 +84,12 @@ namespace copy_tests {
template <class T>
void copy_construct_tests2(T*, test::random_generator const& generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
typename T::hasher hf(1);
typename T::key_equal eq(1);
typename T::allocator_type al(1);
typename T::allocator_type al2(2);
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
typedef typename T::allocator_type allocator_type;
{
test::check_instances check_;

View File

@@ -0,0 +1,352 @@
// Copyright 2017-2018 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)
#include <boost/unordered_map.hpp>
#include <iostream>
#include <vector>
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
struct hash_equals
{
template <typename T> bool operator()(T const& x) const
{
boost::hash<T> hf;
return hf(x);
}
template <typename T> bool operator()(T const& x, T const& y) const
{
std::equal_to<T> eq;
return eq(x, y);
}
};
template <typename T> struct test_allocator
{
typedef T value_type;
test_allocator() = default;
template <typename T2> test_allocator(test_allocator<T2> const&) {}
T* allocate(std::size_t n) const { return (T*)malloc(sizeof(T) * n); }
void deallocate(T* ptr, std::size_t) const { free(ptr); }
bool operator==(test_allocator const&) { return true; }
bool operator!=(test_allocator const&) { return false; }
};
#endif
int main()
{
std::cout << "BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES: "
<< BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES << std::endl;
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
std::vector<std::pair<int, int> > x;
x.push_back(std::make_pair(1, 3));
x.push_back(std::make_pair(5, 10));
test_allocator<std::pair<const int, int> > pair_allocator;
hash_equals f;
// unordered_map
/*
template<class InputIterator,
class Hash = hash<iter_key_t<InputIterator>>,
class Pred = equal_to<iter_key_t<InputIterator>>,
class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
unordered_map(InputIterator, InputIterator, typename see below::size_type =
see below,
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
-> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
Hash, Pred,
Allocator>;
*/
{
boost::unordered_map m(x.begin(), x.end());
static_assert(
std::is_same<decltype(m), boost::unordered_map<int, int> >::value);
}
/* Ambiguous:
{
boost::unordered_map m(x.begin(), x.end(), 0, std::hash<int>());
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
std::hash<int>>>::value);
}
{
boost::unordered_map m(x.begin(), x.end(), 0, std::hash<int>(),
std::equal_to<int>());
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
std::hash<int>, std::equal_to<int>>>::value);
}
*/
{
boost::unordered_map m(x.begin(), x.end(), 0, std::hash<int>(),
std::equal_to<int>(), pair_allocator);
static_assert(std::is_same<decltype(m),
boost::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
test_allocator<std::pair<const int, int> > > >::value);
}
/*
template<class Key, class T, class Hash = hash<Key>,
class Pred = equal_to<Key>, class Allocator = allocator<pair<const
Key, T>>>
unordered_map(initializer_list<pair<const Key, T>>,
typename see below::size_type = see below, Hash = Hash(),
Pred = Pred(), Allocator = Allocator())
-> unordered_map<Key, T, Hash, Pred, Allocator>;
*/
{
boost::unordered_map m({std::pair<int const, int>(1, 2)});
static_assert(
std::is_same<decltype(m), boost::unordered_map<int, int> >::value);
}
/* Ambiguous
{
boost::unordered_map m({std::pair<int const, int>(1,2)}, 0,
std::hash<int>());
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
std::hash<int>>>::value);
}
{
boost::unordered_map m({std::pair<int const, int>(1,2)}, 0,
std::hash<int>(), std::equal_to<int>());
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
std::hash<int>, std::equal_to<int>>>::value);
}
*/
{
boost::unordered_map m(
{std::pair<int const, int>(1, 2)}, 0, f, f, pair_allocator);
static_assert(std::is_same<decltype(m),
boost::unordered_map<int, int, hash_equals, hash_equals,
test_allocator<std::pair<const int, int> > > >::value);
}
/*
template<class InputIterator, class Allocator>
unordered_map(InputIterator, InputIterator, typename see below::size_type,
Allocator)
-> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
hash<iter_key_t<InputIterator>>,
equal_to<iter_key_t<InputIterator>>,
Allocator>;
*/
/* Ambiguous
{
boost::unordered_map m(x.begin(), x.end(), 0u, pair_allocator);
static_assert(std::is_same<decltype(m), boost::unordered_map<int, int,
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
/*
template<class InputIterator, class Allocator>
unordered_map(InputIterator, InputIterator, Allocator)
-> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
hash<iter_key_t<InputIterator>>,
equal_to<iter_key_t<InputIterator>>,
Allocator>;
*/
/* No constructor:
{
boost::unordered_map m(x.begin(), x.end(), pair_allocator);
static_assert(std::is_same<decltype(m), boost::unordered_map<int, int,
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
/*
template<class InputIterator, class Hash, class Allocator>
unordered_map(InputIterator, InputIterator, typename see below::size_type,
Hash, Allocator)
-> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
Hash,
equal_to<iter_key_t<InputIterator>>, Allocator>;
*/
/* Ambiguous
{
boost::unordered_map m(x.begin(), x.end(), 0u, f, pair_allocator);
static_assert(std::is_same<decltype(m), boost::unordered_map<int, int,
hash_equals, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
/*
template<class Key, class T, typename Allocator>
unordered_map(initializer_list<pair<const Key, T>>, typename see
below::size_type,
Allocator)
-> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>;
*/
/* Ambiguous
{
boost::unordered_map m({std::pair<int const, int>(1,2)}, 0, pair_allocator);
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
/*
template<class Key, class T, typename Allocator>
unordered_map(initializer_list<pair<const Key, T>>, Allocator)
-> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>;
*/
{
boost::unordered_map m({std::pair<int const, int>(1, 2)}, pair_allocator);
static_assert(std::is_same<decltype(m),
boost::unordered_map<int, int, boost::hash<int>, std::equal_to<int>,
test_allocator<std::pair<const int, int> > > >::value);
}
/*
template<class Key, class T, class Hash, class Allocator>
unordered_map(initializer_list<pair<const Key, T>>, typename see
below::size_type, Hash,
Allocator)
-> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>;
*/
/* Ambiguous
{
boost::unordered_map m({std::pair<int const, int>(1,2)}, 0, f,
pair_allocator);
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
// unordered_multimap
{
boost::unordered_multimap m(x.begin(), x.end());
static_assert(
std::is_same<decltype(m), boost::unordered_multimap<int, int> >::value);
}
/* Ambiguous:
{
boost::unordered_multimap m(x.begin(), x.end(), 0, std::hash<int>());
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
std::hash<int>>>::value);
}
{
boost::unordered_multimap m(x.begin(), x.end(), 0, std::hash<int>(),
std::equal_to<int>());
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
std::hash<int>, std::equal_to<int>>>::value);
}
*/
{
boost::unordered_multimap m(x.begin(), x.end(), 0, std::hash<int>(),
std::equal_to<int>(), pair_allocator);
static_assert(std::is_same<decltype(m),
boost::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
test_allocator<std::pair<const int, int> > > >::value);
}
{
boost::unordered_multimap m({std::pair<int const, int>(1, 2)});
static_assert(
std::is_same<decltype(m), boost::unordered_multimap<int, int> >::value);
}
/* Ambiguous
{
boost::unordered_multimap m({std::pair<int const, int>(1,2)}, 0,
std::hash<int>());
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
std::hash<int>>>::value);
}
{
boost::unordered_multimap m({std::pair<int const, int>(1,2)}, 0,
std::hash<int>(), std::equal_to<int>());
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
std::hash<int>, std::equal_to<int>>>::value);
}
*/
{
boost::unordered_multimap m(
{std::pair<int const, int>(1, 2)}, 0, f, f, pair_allocator);
static_assert(std::is_same<decltype(m),
boost::unordered_multimap<int, int, hash_equals, hash_equals,
test_allocator<std::pair<const int, int> > > >::value);
}
/* Ambiguous
{
boost::unordered_multimap m(x.begin(), x.end(), 0u, pair_allocator);
static_assert(std::is_same<decltype(m), boost::unordered_multimap<int, int,
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
/* No constructor:
{
boost::unordered_multimap m(x.begin(), x.end(), pair_allocator);
static_assert(std::is_same<decltype(m), boost::unordered_multimap<int, int,
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
/* Ambiguous
{
boost::unordered_multimap m(x.begin(), x.end(), 0u, f, pair_allocator);
static_assert(std::is_same<decltype(m), boost::unordered_multimap<int, int,
hash_equals, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
{
boost::unordered_multimap m({std::pair<int const, int>(1,2)}, 0,
pair_allocator);
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
{
boost::unordered_multimap m(
{std::pair<int const, int>(1, 2)}, pair_allocator);
static_assert(std::is_same<decltype(m),
boost::unordered_multimap<int, int, boost::hash<int>, std::equal_to<int>,
test_allocator<std::pair<const int, int> > > >::value);
}
/* Ambiguous
{
boost::unordered_multimap m({std::pair<int const, int>(1,2)}, 0, f,
pair_allocator);
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
int>>>>::value);
}
*/
#endif
}

View File

@@ -31,36 +31,36 @@ namespace equality_tests {
};
#define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \
do { \
{ \
boost::unordered_set<int, mod_compare, mod_compare> set1, set2; \
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
BOOST_TEST(set1 op set2); \
} while (0)
}
#define UNORDERED_EQUALITY_MULTISET_TEST(seq1, op, seq2) \
do { \
{ \
boost::unordered_multiset<int, mod_compare, mod_compare> set1, set2; \
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
BOOST_TEST(set1 op set2); \
} while (0)
}
#define UNORDERED_EQUALITY_MAP_TEST(seq1, op, seq2) \
do { \
{ \
boost::unordered_map<int, int, mod_compare, mod_compare> map1, map2; \
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
BOOST_TEST(map1 op map2); \
} while (0)
}
#define UNORDERED_EQUALITY_MULTIMAP_TEST(seq1, op, seq2) \
do { \
{ \
boost::unordered_multimap<int, int, mod_compare, mod_compare> map1, map2; \
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
BOOST_TEST(map1 op map2); \
} while (0)
}
#define UNORDERED_SET_INSERT(r, set, item) set.insert(item);
#define UNORDERED_MAP_INSERT(r, map, item) \
@@ -89,46 +89,45 @@ namespace equality_tests {
}
UNORDERED_AUTO_TEST (equality_key_value_tests) {
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2));
UNORDERED_EQUALITY_SET_TEST((2), ==, (2));
UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)));
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2))
UNORDERED_EQUALITY_SET_TEST((2), ==, (2))
UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)))
}
UNORDERED_AUTO_TEST (equality_collision_test) {
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (501));
UNORDERED_EQUALITY_MULTISET_TEST((1)(251), !=, (1)(501));
UNORDERED_EQUALITY_MULTIMAP_TEST(
((251)(1))((1)(1)), !=, ((501)(1))((1)(1)));
UNORDERED_EQUALITY_MULTISET_TEST((1)(501), ==, (1)(501));
UNORDERED_EQUALITY_SET_TEST((1)(501), ==, (501)(1));
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (501))
UNORDERED_EQUALITY_MULTISET_TEST((1)(251), !=, (1)(501))
UNORDERED_EQUALITY_MULTIMAP_TEST(((251)(1))((1)(1)), !=, ((501)(1))((1)(1)))
UNORDERED_EQUALITY_MULTISET_TEST((1)(501), ==, (1)(501))
UNORDERED_EQUALITY_SET_TEST((1)(501), ==, (501)(1))
}
UNORDERED_AUTO_TEST (equality_group_size_test) {
UNORDERED_EQUALITY_MULTISET_TEST((10)(20)(20), !=, (10)(10)(20));
UNORDERED_EQUALITY_MULTISET_TEST((10)(20)(20), !=, (10)(10)(20))
UNORDERED_EQUALITY_MULTIMAP_TEST(
((10)(1))((20)(1))((20)(1)), !=, ((10)(1))((20)(1))((10)(1)));
((10)(1))((20)(1))((20)(1)), !=, ((10)(1))((20)(1))((10)(1)))
UNORDERED_EQUALITY_MULTIMAP_TEST(
((20)(1))((10)(1))((10)(1)), ==, ((10)(1))((20)(1))((10)(1)));
((20)(1))((10)(1))((10)(1)), ==, ((10)(1))((20)(1))((10)(1)))
}
UNORDERED_AUTO_TEST (equality_map_value_test) {
UNORDERED_EQUALITY_MAP_TEST(((1)(1)), !=, ((1)(2)));
UNORDERED_EQUALITY_MAP_TEST(((1)(1)), ==, ((1)(1)));
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(1)), !=, ((1)(2)));
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(1))((1)(1)), !=, ((1)(1))((1)(2)));
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(2))((1)(1)), ==, ((1)(1))((1)(2)));
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(2))((1)(1)), !=, ((1)(1))((1)(3)));
UNORDERED_EQUALITY_MAP_TEST(((1)(1)), !=, ((1)(2)))
UNORDERED_EQUALITY_MAP_TEST(((1)(1)), ==, ((1)(1)))
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(1)), !=, ((1)(2)))
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(1))((1)(1)), !=, ((1)(1))((1)(2)))
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(2))((1)(1)), ==, ((1)(1))((1)(2)))
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(2))((1)(1)), !=, ((1)(1))((1)(3)))
}
UNORDERED_AUTO_TEST (equality_predicate_test) {
UNORDERED_EQUALITY_SET_TEST((1), !=, (1001));
UNORDERED_EQUALITY_MAP_TEST(((1)(2))((1001)(1)), !=, ((1001)(2))((1)(1)));
UNORDERED_EQUALITY_SET_TEST((1), !=, (1001))
UNORDERED_EQUALITY_MAP_TEST(((1)(2))((1001)(1)), !=, ((1001)(2))((1)(1)))
}
UNORDERED_AUTO_TEST (equality_multiple_group_test) {
UNORDERED_EQUALITY_MULTISET_TEST(
(1)(1)(1)(1001)(2001)(2001)(2)(1002)(3)(1003)(2003), ==,
(3)(1003)(2003)(1002)(2)(2001)(2001)(1)(1001)(1)(1));
(3)(1003)(2003)(1002)(2)(2001)(2001)(1)(1001)(1)(1))
}
// Test that equality still works when the two containers have

View File

@@ -27,8 +27,8 @@ namespace erase_tests {
template <class Container>
void erase_tests1(Container*, test::random_generator generator)
{
typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME Container::const_iterator c_iterator;
typedef typename Container::iterator iterator;
typedef typename Container::const_iterator c_iterator;
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Erase by key.\n";
{
@@ -37,8 +37,7 @@ namespace erase_tests {
test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
int iterations = 0;
for (BOOST_DEDUCED_TYPENAME test::random_values<Container>::iterator it =
v.begin();
for (typename test::random_values<Container>::iterator it = v.begin();
it != v.end(); ++it) {
std::size_t count = x.count(test::get_key<Container>(*it));
std::size_t old_size = x.size();
@@ -60,8 +59,7 @@ namespace erase_tests {
std::size_t size = x.size();
int iterations = 0;
while (size > 0 && !x.empty()) {
BOOST_DEDUCED_TYPENAME Container::key_type key =
test::get_key<Container>(*x.begin());
typename Container::key_type key = test::get_key<Container>(*x.begin());
std::size_t count = x.count(key);
iterator pos = x.erase(x.begin());
--size;
@@ -92,8 +90,7 @@ namespace erase_tests {
pos = test::next(prev);
}
next = test::next(pos);
BOOST_DEDUCED_TYPENAME Container::key_type key =
test::get_key<Container>(*pos);
typename Container::key_type key = test::get_key<Container>(*pos);
std::size_t count = x.count(key);
BOOST_TEST(count > 0);
BOOST_TEST(next == x.erase(pos));
@@ -163,7 +160,7 @@ namespace erase_tests {
test::next(iterators.begin(), start + length));
BOOST_TEST(x.size() == iterators.size() - 1);
BOOST_DEDUCED_TYPENAME std::vector<c_iterator>::const_iterator i2 =
typename std::vector<c_iterator>::const_iterator i2 =
iterators.begin();
for (c_iterator i1 = x.cbegin(); i1 != x.cend(); ++i1) {
BOOST_TEST(i1 == *i2);
@@ -186,8 +183,7 @@ namespace erase_tests {
std::size_t size = x.size();
int iterations = 0;
while (size > 0 && !x.empty()) {
BOOST_DEDUCED_TYPENAME Container::key_type key =
test::get_key<Container>(*x.begin());
typename Container::key_type key = test::get_key<Container>(*x.begin());
std::size_t count = x.count(key);
x.quick_erase(x.begin());
--size;
@@ -209,7 +205,7 @@ namespace erase_tests {
int iterations = 0;
while (size > 0 && !x.empty()) {
std::size_t index = test::random_value(x.size());
BOOST_DEDUCED_TYPENAME Container::const_iterator prev, pos, next;
typename Container::const_iterator prev, pos, next;
if (index == 0) {
prev = pos = x.begin();
} else {
@@ -217,8 +213,7 @@ namespace erase_tests {
pos = test::next(prev);
}
next = test::next(pos);
BOOST_DEDUCED_TYPENAME Container::key_type key =
test::get_key<Container>(*pos);
typename Container::key_type key = test::get_key<Container>(*pos);
std::size_t count = x.count(key);
BOOST_TEST(count > 0);
x.quick_erase(pos);

View File

@@ -17,7 +17,6 @@
#include "../helpers/test.hpp"
#include "../helpers/tracker.hpp"
#include "../objects/test.hpp"
#include <boost/next_prior.hpp>
namespace extract_tests {
@@ -33,8 +32,7 @@ namespace extract_tests {
test::random_values<Container> v(1000, generator);
Container x(v.begin(), v.end());
int iterations = 0;
for (BOOST_DEDUCED_TYPENAME test::random_values<Container>::iterator it =
v.begin();
for (typename test::random_values<Container>::iterator it = v.begin();
it != v.end(); ++it) {
std::size_t count = x.count(test::get_key<Container>(*it));
std::size_t old_size = x.size();
@@ -65,8 +63,7 @@ namespace extract_tests {
std::size_t size = x.size();
int iterations = 0;
while (size > 0 && !x.empty()) {
BOOST_DEDUCED_TYPENAME Container::key_type key =
test::get_key<Container>(*x.begin());
typename Container::key_type key = test::get_key<Container>(*x.begin());
std::size_t count = x.count(key);
typename Container::node_type n = x.extract(x.begin());
BOOST_TEST(n);
@@ -90,23 +87,21 @@ namespace extract_tests {
while (size > 0 && !x.empty()) {
using namespace std;
int index = rand() % (int)x.size();
BOOST_DEDUCED_TYPENAME Container::const_iterator prev, pos, next;
typename Container::const_iterator prev, pos, next;
if (index == 0) {
prev = pos = x.begin();
} else {
prev = boost::next(x.begin(), index - 1);
pos = boost::next(prev);
prev = test::next(x.begin(), index - 1);
pos = test::next(prev);
}
next = boost::next(pos);
BOOST_DEDUCED_TYPENAME Container::key_type key =
test::get_key<Container>(*pos);
next = test::next(pos);
typename Container::key_type key = test::get_key<Container>(*pos);
std::size_t count = x.count(key);
typename Container::node_type n = x.extract(pos);
BOOST_TEST(n);
--size;
if (size > 0)
BOOST_TEST(
index == 0 ? next == x.begin() : next == boost::next(prev));
BOOST_TEST(index == 0 ? next == x.begin() : next == test::next(prev));
BOOST_TEST(x.count(key) == count - 1);
BOOST_TEST(x.size() == size);
if (++iterations % 20 == 0)

View File

@@ -22,7 +22,7 @@ namespace find_tests {
template <class X> void find_tests1(X*, test::random_generator generator)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
{
test::check_instances check_;
@@ -33,11 +33,10 @@ namespace find_tests {
test::ordered<X> tracker = test::create_ordered(x);
tracker.insert_range(v.begin(), v.end());
for (BOOST_DEDUCED_TYPENAME test::ordered<X>::const_iterator it1 =
tracker.begin();
for (typename test::ordered<X>::const_iterator it1 = tracker.begin();
it1 != tracker.end(); ++it1) {
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it1);
BOOST_DEDUCED_TYPENAME X::const_iterator const_pos = x_const.find(key);
typename X::key_type key = test::get_key<X>(*it1);
typename X::const_iterator const_pos = x_const.find(key);
iterator pos = x.find(key);
BOOST_TEST(const_pos != x_const.end());
BOOST_TEST(const_pos != x_const.end() &&
@@ -48,16 +47,15 @@ namespace find_tests {
BOOST_TEST(x.count(key) == tracker.count(key));
test::compare_pairs(x.equal_range(key), tracker.equal_range(key),
(BOOST_DEDUCED_TYPENAME X::value_type*)0);
(typename X::value_type*)0);
test::compare_pairs(x_const.equal_range(key), tracker.equal_range(key),
(BOOST_DEDUCED_TYPENAME X::value_type*)0);
(typename X::value_type*)0);
}
test::random_values<X> v2(500, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator it2 =
v2.begin();
for (typename test::random_values<X>::const_iterator it2 = v2.begin();
it2 != v2.end(); ++it2) {
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it2);
typename X::key_type key = test::get_key<X>(*it2);
if (tracker.find(test::get_key<X>(key)) == tracker.end()) {
BOOST_TEST(x.find(key) == x.end());
BOOST_TEST(x_const.find(key) == x_const.end());
@@ -74,10 +72,9 @@ namespace find_tests {
X x;
test::random_values<X> v2(5, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator it3 =
v2.begin();
for (typename test::random_values<X>::const_iterator it3 = v2.begin();
it3 != v2.end(); ++it3) {
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it3);
typename X::key_type key = test::get_key<X>(*it3);
BOOST_TEST(x.find(key) == x.end());
BOOST_TEST(x.count(key) == 0);
std::pair<iterator, iterator> range = x.equal_range(key);
@@ -116,8 +113,7 @@ namespace find_tests {
template <class X>
void find_compatible_keys_test(X*, test::random_generator generator)
{
typedef BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator
value_iterator;
typedef typename test::random_values<X>::iterator value_iterator;
test::random_values<X> v(500, generator);
X x(v.begin(), v.end());
@@ -125,14 +121,14 @@ namespace find_tests {
compatible_predicate eq;
for (value_iterator it = v.begin(), end = v.end(); it != end; ++it) {
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it);
typename X::key_type key = test::get_key<X>(*it);
BOOST_TEST(x.find(key) == x.find(compatible_key(key), h, eq));
}
test::random_values<X> v2(20, generator);
for (value_iterator it = v2.begin(), end = v2.end(); it != end; ++it) {
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it);
typename X::key_type key = test::get_key<X>(*it);
BOOST_TEST(x.find(key) == x.find(compatible_key(key), h, eq));
}
}

View File

@@ -30,7 +30,7 @@ namespace insert_tests {
{
test::check_instances check_;
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
typedef test::ordered<X> ordered;
UNORDERED_SUB_TEST("insert(value) tests for containers with unique keys")
@@ -40,16 +40,14 @@ namespace insert_tests {
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
std::pair<iterator, bool> r1 = x.insert(*it);
std::pair<BOOST_DEDUCED_TYPENAME ordered::iterator, bool> r2 =
tracker.insert(*it);
std::pair<typename ordered::iterator, bool> r2 = tracker.insert(*it);
BOOST_TEST(r1.second == r2.second);
BOOST_TEST(*r1.first == *r2.first);
@@ -71,17 +69,15 @@ namespace insert_tests {
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
typename X::value_type value = *it;
std::pair<iterator, bool> r1 = x.insert(boost::move(value));
std::pair<BOOST_DEDUCED_TYPENAME ordered::iterator, bool> r2 =
tracker.insert(*it);
std::pair<typename ordered::iterator, bool> r2 = tracker.insert(*it);
BOOST_TEST(r1.second == r2.second);
BOOST_TEST(*r1.first == *r2.first);
@@ -109,15 +105,13 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
BOOST_DEDUCED_TYPENAME X::iterator r1 = x.insert(*it);
BOOST_DEDUCED_TYPENAME test::ordered<X>::iterator r2 =
tracker.insert(*it);
typename X::iterator r1 = x.insert(*it);
typename test::ordered<X>::iterator r2 = tracker.insert(*it);
BOOST_TEST(*r1 == *r2);
@@ -138,16 +132,14 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
typename X::value_type value = *it;
BOOST_DEDUCED_TYPENAME X::iterator r1 = x.insert(boost::move(value));
BOOST_DEDUCED_TYPENAME test::ordered<X>::iterator r2 =
tracker.insert(*it);
typename X::iterator r1 = x.insert(boost::move(value));
typename test::ordered<X>::iterator r2 = tracker.insert(*it);
BOOST_TEST(*r1 == *r2);
@@ -164,10 +156,10 @@ namespace insert_tests {
template <class X> void insert_tests2(X*, test::random_generator generator)
{
typedef BOOST_DEDUCED_TYPENAME test::ordered<X> tracker_type;
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME tracker_type::iterator tracker_iterator;
typedef typename test::ordered<X> tracker_type;
typedef typename X::iterator iterator;
typedef typename X::const_iterator const_iterator;
typedef typename tracker_type::iterator tracker_iterator;
UNORDERED_SUB_TEST("insert(begin(), value) tests")
{
@@ -177,10 +169,9 @@ namespace insert_tests {
tracker_type tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
iterator r1 = x.insert(x.begin(), *it);
@@ -206,10 +197,9 @@ namespace insert_tests {
tracker_type tracker = test::create_ordered(x);
test::random_values<X> v(100, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
const_iterator r1 = x.insert(x_const.end(), *it);
@@ -235,10 +225,9 @@ namespace insert_tests {
tracker_type tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
pos = x.insert(pos, *it);
@@ -264,10 +253,9 @@ namespace insert_tests {
tracker_type tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
typename X::value_type value = *it;
@@ -293,10 +281,9 @@ namespace insert_tests {
tracker_type tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
x.insert(it, test::next(it));
@@ -349,10 +336,8 @@ namespace insert_tests {
X x;
test::random_values<X> v(1000, generator);
BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator begin =
v.begin(),
end =
v.end();
typename test::random_values<X>::const_iterator begin = v.begin(),
end = v.end();
x.insert(test::input_iterator(begin), test::input_iterator(end));
test::check_container(x, v);
@@ -394,14 +379,12 @@ namespace insert_tests {
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end();) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count =
x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator next = it;
typename test::random_values<X>::iterator next = it;
for (std::size_t j = test::random_value(20); j > 0; ++j) {
++next;
if (next == v.end()) {
@@ -428,7 +411,7 @@ namespace insert_tests {
template <class X>
void unique_emplace_tests1(X*, test::random_generator generator)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
typedef test::ordered<X> ordered;
X x;
@@ -436,15 +419,14 @@ namespace insert_tests {
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
std::pair<iterator, bool> r1 = x.emplace(*it);
std::pair<BOOST_DEDUCED_TYPENAME ordered::iterator, bool> r2 =
tracker.insert(*it);
std::pair<typename ordered::iterator, bool> r2 = tracker.insert(*it);
BOOST_TEST(r1.second == r2.second);
BOOST_TEST(*r1.first == *r2.first);
@@ -467,14 +449,13 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
BOOST_DEDUCED_TYPENAME X::iterator r1 = x.emplace(*it);
BOOST_DEDUCED_TYPENAME test::ordered<X>::iterator r2 =
tracker.insert(*it);
typename X::iterator r1 = x.emplace(*it);
typename test::ordered<X>::iterator r2 = tracker.insert(*it);
BOOST_TEST(*r1 == *r2);
@@ -497,10 +478,10 @@ namespace insert_tests {
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
typename X::value_type value = *it;
@@ -558,9 +539,9 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
x[it->first] = it->second;
@@ -579,7 +560,7 @@ namespace insert_tests {
template <class X> void map_tests2(X*, test::random_generator generator)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
UNORDERED_SUB_TEST("insert_or_assign")
{
@@ -589,10 +570,9 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
std::pair<iterator, bool> r = x.insert_or_assign(it->first, it->second);
@@ -618,10 +598,9 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
iterator r = x.insert_or_assign(x.begin(), it->first, it->second);
@@ -647,10 +626,9 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
iterator r = x.insert_or_assign(x.end(), it->first, it->second);
@@ -677,10 +655,9 @@ namespace insert_tests {
iterator last = x.begin();
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
iterator r = x.insert_or_assign(last, it->first, it->second);
@@ -704,7 +681,7 @@ namespace insert_tests {
template <class X>
void try_emplace_tests(X*, test::random_generator generator)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
UNORDERED_SUB_TEST("try_emplace(key, value)")
{
@@ -714,10 +691,9 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
iterator pos = x.find(it->first);
@@ -745,7 +721,7 @@ namespace insert_tests {
test::check_equivalent_keys(x);
}
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
UNORDERED_SUB_TEST("try_emplace(begin(), key, value)")
{
@@ -755,10 +731,9 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
iterator pos = x.find(it->first);
@@ -783,7 +758,7 @@ namespace insert_tests {
test::check_equivalent_keys(x);
}
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
UNORDERED_SUB_TEST("try_emplace(end(), key, value)")
{
@@ -793,10 +768,9 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
iterator pos = x.find(it->first);
@@ -820,7 +794,7 @@ namespace insert_tests {
test::check_equivalent_keys(x);
}
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef typename X::iterator iterator;
UNORDERED_SUB_TEST("try_emplace(pos, key, value)")
{
@@ -830,10 +804,9 @@ namespace insert_tests {
test::ordered<X> tracker = test::create_ordered(x);
test::random_values<X> v(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
v.begin();
for (typename test::random_values<X>::iterator it = v.begin();
it != v.end(); ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
typename X::size_type old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
iterator pos = x.find(it->first);
@@ -866,8 +839,8 @@ namespace insert_tests {
{
test::check_instances check_;
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type,
BOOST_DEDUCED_TYPENAME X::mapped_type> >
typedef test::list<
std::pair<typename X::key_type, typename X::mapped_type> >
list;
test::random_values<X> v(1000, generator);
list l(v.begin(), v.end());
@@ -883,11 +856,11 @@ namespace insert_tests {
{
test::check_instances check_;
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type const,
test::implicitly_convertible> >
typedef test::list<
std::pair<typename X::key_type const, test::implicitly_convertible> >
list;
test::random_values<boost::unordered_map<BOOST_DEDUCED_TYPENAME X::key_type,
test::implicitly_convertible> >
test::random_values<
boost::unordered_map<typename X::key_type, test::implicitly_convertible> >
v(1000, generator);
list l(v.begin(), v.end());

View File

@@ -13,7 +13,7 @@
void foo(boost::unordered_set<int>& x1, boost::unordered_map<int, int>& x2,
boost::unordered_multiset<int>& x3, boost::unordered_multimap<int, int>& x4)
{
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
#if BOOST_WORKAROUND(BOOST_CODEGEARC, BOOST_TESTED_AT(0x0613))
struct dummy
{
boost::unordered_set<int> x1;

View File

@@ -47,12 +47,11 @@ namespace load_factor_tests {
test::random_values<X> values(1000, generator);
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
it = values.begin(),
end = values.end();
for (typename test::random_values<X>::const_iterator it = values.begin(),
end = values.end();
it != end; ++it) {
BOOST_DEDUCED_TYPENAME X::size_type old_size = x.size(),
old_bucket_count = x.bucket_count();
typename X::size_type old_size = x.size(),
old_bucket_count = x.bucket_count();
x.insert(*it);
if (static_cast<double>(old_size + 1) <=
b * static_cast<double>(old_bucket_count))

View File

@@ -15,7 +15,6 @@
#include "../helpers/test.hpp"
#include "../helpers/tracker.hpp"
#include "../objects/test.hpp"
#include <boost/next_prior.hpp>
namespace merge_tests {
@@ -174,8 +173,8 @@ namespace merge_tests {
test::random_values<X1> v1(1000, generator);
test::random_values<X2> v2(1000, generator);
v1.insert(v2.begin(), boost::next(v2.begin(), 100));
v2.insert(v1.begin(), boost::next(v1.begin(), 100));
v1.insert(v2.begin(), test::next(v2.begin(), 100));
v2.insert(v1.begin(), test::next(v1.begin(), 100));
X1 x1(v1.begin(), v1.end(), 0, test::hash(hash_equal1),
test::equal_to(hash_equal1));
@@ -207,8 +206,8 @@ namespace merge_tests {
test::random_values<X1> v1(1000, generator);
test::random_values<X2> v2(1000, generator);
v1.insert(v2.begin(), boost::next(v2.begin(), 100));
v2.insert(v1.begin(), boost::next(v1.begin(), 100));
v1.insert(v2.begin(), test::next(v2.begin(), 100));
v2.insert(v1.begin(), test::next(v1.begin(), 100));
X1 x1(v1.begin(), v1.end(), 0, test::hash(hash_equal1),
test::equal_to(hash_equal1));

View File

@@ -4,7 +4,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "../objects/test.hpp"
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/unordered/detail/implementation.hpp>

View File

@@ -43,8 +43,8 @@ namespace move_tests {
template <class T>
T create(test::random_values<T> const& v, test::object_count& count,
BOOST_DEDUCED_TYPENAME T::hasher hf, BOOST_DEDUCED_TYPENAME T::key_equal eq,
BOOST_DEDUCED_TYPENAME T::allocator_type al, float mlf)
typename T::hasher hf, typename T::key_equal eq,
typename T::allocator_type al, float mlf)
{
T x(0, hf, eq, al);
x.max_load_factor(mlf);
@@ -56,9 +56,9 @@ namespace move_tests {
template <class T>
void move_construct_tests1(T* ptr, test::random_generator const& generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf;
BOOST_DEDUCED_TYPENAME T::key_equal eq;
BOOST_DEDUCED_TYPENAME T::allocator_type al;
typename T::hasher hf;
typename T::key_equal eq;
typename T::allocator_type al;
{
test::check_instances check_;
@@ -107,10 +107,10 @@ namespace move_tests {
template <class T>
void move_construct_tests2(T*, test::random_generator const& generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
typename T::hasher hf(1);
typename T::key_equal eq(1);
typename T::allocator_type al(1);
typename T::allocator_type al2(2);
test::object_count count;
@@ -180,11 +180,11 @@ namespace move_tests {
template <class T>
void move_assign_tests2(T*, test::random_generator const& generator)
{
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
typename T::hasher hf(1);
typename T::key_equal eq(1);
typename T::allocator_type al1(1);
typename T::allocator_type al2(2);
typedef typename T::allocator_type allocator_type;
{
test::random_values<T> v(500, generator);

View File

@@ -11,6 +11,7 @@
#include "../helpers/helpers.hpp"
#include "../helpers/metafunctions.hpp"
#include "../helpers/test.hpp"
#include <boost/core/pointer_traits.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <set>
@@ -146,24 +147,24 @@ UNORDERED_AUTO_TEST (failed_insertion_with_hint) {
template <typename NodeHandle>
bool node_handle_compare(
NodeHandle const& nh, BOOST_DEDUCED_TYPENAME NodeHandle::value_type const& x)
NodeHandle const& nh, typename NodeHandle::value_type const& x)
{
return x == nh.value();
}
template <typename NodeHandle>
bool node_handle_compare(NodeHandle const& nh,
std::pair<BOOST_DEDUCED_TYPENAME NodeHandle::key_type const,
BOOST_DEDUCED_TYPENAME NodeHandle::mapped_type> const& x)
bool node_handle_compare(
NodeHandle const& nh, std::pair<typename NodeHandle::key_type const,
typename NodeHandle::mapped_type> const& x)
{
return x.first == nh.key() && x.second == nh.mapped();
}
template <typename Container> void node_handle_tests_impl(Container& c)
{
typedef BOOST_DEDUCED_TYPENAME Container::node_type node_type;
typedef typename Container::node_type node_type;
BOOST_DEDUCED_TYPENAME Container::value_type value = *c.begin();
typename Container::value_type value = *c.begin();
node_type n1;
BOOST_TEST(!n1);
@@ -194,9 +195,9 @@ template <typename Container> void node_handle_tests_impl(Container& c)
n3 = boost::move(n3);
BOOST_TEST(!n3);
BOOST_DEDUCED_TYPENAME Container::value_type value1 = *c.begin();
typename Container::value_type value1 = *c.begin();
n1 = c.extract(c.begin());
BOOST_DEDUCED_TYPENAME Container::value_type value2 = *c.begin();
typename Container::value_type value2 = *c.begin();
n2 = c.extract(c.begin());
n3 = node_type();
@@ -247,15 +248,13 @@ UNORDERED_AUTO_TEST (node_handle_tests) {
template <typename Container1, typename Container2>
void insert_node_handle_unique(Container1& c1, Container2& c2)
{
typedef BOOST_DEDUCED_TYPENAME Container1::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_type;
BOOST_STATIC_ASSERT(boost::is_same<node_type,
BOOST_DEDUCED_TYPENAME Container2::node_type>::value);
typedef typename Container1::node_type node_type;
typedef typename Container1::value_type value_type;
BOOST_STATIC_ASSERT(
(boost::is_same<node_type, typename Container2::node_type>::value));
typedef BOOST_DEDUCED_TYPENAME Container1::insert_return_type
insert_return_type1;
typedef BOOST_DEDUCED_TYPENAME Container2::insert_return_type
insert_return_type2;
typedef typename Container1::insert_return_type insert_return_type1;
typedef typename Container2::insert_return_type insert_return_type2;
insert_return_type1 r1 = c1.insert(node_type());
insert_return_type2 r2 = c2.insert(node_type());
@@ -268,14 +267,14 @@ void insert_node_handle_unique(Container1& c1, Container2& c2)
while (!c1.empty()) {
value_type v = *c1.begin();
value_type const* v_ptr = boost::addressof(*c1.begin());
value_type const* v_ptr = boost::to_address(c1.begin());
std::size_t count = c2.count(test::get_key<Container1>(v));
insert_return_type2 r = c2.insert(c1.extract(c1.begin()));
if (!count) {
BOOST_TEST(r.inserted);
BOOST_TEST_EQ(c2.count(test::get_key<Container1>(v)), count + 1);
BOOST_TEST(r.position != c2.end());
BOOST_TEST(boost::addressof(*r.position) == v_ptr);
BOOST_TEST(boost::to_address(r.position) == v_ptr);
BOOST_TEST(!r.node);
} else {
BOOST_TEST(!r.inserted);
@@ -292,25 +291,24 @@ void insert_node_handle_unique(Container1& c1, Container2& c2)
template <typename Container1, typename Container2>
void insert_node_handle_unique2(Container1& c1, Container2& c2)
{
typedef BOOST_DEDUCED_TYPENAME Container1::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_type;
BOOST_STATIC_ASSERT(boost::is_same<node_type,
BOOST_DEDUCED_TYPENAME Container2::node_type>::value);
typedef typename Container1::node_type node_type;
typedef typename Container1::value_type value_type;
BOOST_STATIC_ASSERT(
(boost::is_same<node_type, typename Container2::node_type>::value));
// typedef BOOST_DEDUCED_TYPENAME Container1::insert_return_type
// typedef typename Container1::insert_return_type
// insert_return_type1;
typedef BOOST_DEDUCED_TYPENAME Container2::insert_return_type
insert_return_type2;
typedef typename Container2::insert_return_type insert_return_type2;
while (!c1.empty()) {
value_type v = *c1.begin();
value_type const* v_ptr = boost::addressof(*c1.begin());
value_type const* v_ptr = boost::to_address(c1.begin());
std::size_t count = c2.count(test::get_key<Container1>(v));
insert_return_type2 r = c2.insert(c1.extract(test::get_key<Container1>(v)));
if (r.inserted) {
BOOST_TEST_EQ(c2.count(test::get_key<Container1>(v)), count + 1);
BOOST_TEST(r.position != c2.end());
BOOST_TEST(boost::addressof(*r.position) == v_ptr);
BOOST_TEST(boost::to_address(r.position) == v_ptr);
BOOST_TEST(!r.node);
} else {
BOOST_TEST_EQ(c2.count(test::get_key<Container1>(v)), count);
@@ -326,13 +324,13 @@ void insert_node_handle_unique2(Container1& c1, Container2& c2)
template <typename Container1, typename Container2>
void insert_node_handle_equiv(Container1& c1, Container2& c2)
{
typedef BOOST_DEDUCED_TYPENAME Container1::node_type node_type;
typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_type;
BOOST_STATIC_ASSERT(boost::is_same<node_type,
BOOST_DEDUCED_TYPENAME Container2::node_type>::value);
typedef typename Container1::node_type node_type;
typedef typename Container1::value_type value_type;
BOOST_STATIC_ASSERT(
(boost::is_same<node_type, typename Container2::node_type>::value));
typedef BOOST_DEDUCED_TYPENAME Container1::iterator iterator1;
typedef BOOST_DEDUCED_TYPENAME Container2::iterator iterator2;
typedef typename Container1::iterator iterator1;
typedef typename Container2::iterator iterator2;
iterator1 r1 = c1.insert(node_type());
iterator2 r2 = c2.insert(node_type());
@@ -341,12 +339,12 @@ void insert_node_handle_equiv(Container1& c1, Container2& c2)
while (!c1.empty()) {
value_type v = *c1.begin();
value_type const* v_ptr = boost::addressof(*c1.begin());
value_type const* v_ptr = boost::to_address(c1.begin());
std::size_t count = c2.count(test::get_key<Container1>(v));
iterator2 r = c2.insert(c1.extract(c1.begin()));
BOOST_TEST_EQ(c2.count(test::get_key<Container1>(v)), count + 1);
BOOST_TEST(r != c2.end());
BOOST_TEST(boost::addressof(*r) == v_ptr);
BOOST_TEST(boost::to_address(r) == v_ptr);
}
}

View File

@@ -12,17 +12,31 @@
#include "../helpers/test.hpp"
#if defined(BOOST_MSVC)
#pragma warning(push)
// conditional expression is constant
#pragma warning(disable : 4127)
#endif
namespace noexcept_tests {
// Test the noexcept is set correctly for the move constructor.
struct hash_possible_exception : boost::hash<int>
{
hash_possible_exception(hash_possible_exception const&) {}
hash_possible_exception& operator=(hash_possible_exception const&)
{
return *this;
}
};
struct equal_to_possible_exception : std::equal_to<int>
{
equal_to_possible_exception(equal_to_possible_exception const&) {}
equal_to_possible_exception& operator=(equal_to_possible_exception const&)
{
return *this;
}
};
// Test that the move constructor does actually move without throwing
@@ -42,25 +56,36 @@ namespace noexcept_tests {
}
}
class hash_nothrow_move : boost::hash<int>
template <bool nothrow_move_construct, bool nothrow_move_assign,
bool nothrow_swap>
class hash_nothrow : boost::hash<int>
{
BOOST_COPYABLE_AND_MOVABLE(hash_nothrow_move)
BOOST_COPYABLE_AND_MOVABLE(hash_nothrow)
typedef boost::hash<int> base;
public:
hash_nothrow_move(BOOST_RV_REF(hash_nothrow_move)) BOOST_NOEXCEPT {}
hash_nothrow(BOOST_RV_REF(hash_nothrow))
BOOST_NOEXCEPT_IF(nothrow_move_construct)
{
if (!nothrow_move_construct) {
test_throw("Move Constructor");
}
}
hash_nothrow_move() { test_throw("Constructor"); }
hash_nothrow_move(hash_nothrow_move const&) { test_throw("Copy"); }
hash_nothrow_move& operator=(BOOST_COPY_ASSIGN_REF(hash_nothrow_move))
hash_nothrow() { test_throw("Constructor"); }
hash_nothrow(hash_nothrow const&) { test_throw("Copy"); }
hash_nothrow& operator=(BOOST_COPY_ASSIGN_REF(hash_nothrow))
{
test_throw("Assign");
return *this;
}
hash_nothrow_move& operator=(BOOST_RV_REF(hash_nothrow_move))
hash_nothrow& operator=(BOOST_RV_REF(hash_nothrow))
BOOST_NOEXCEPT_IF(nothrow_move_assign)
{
test_throw("Move Assign");
if (!nothrow_move_assign) {
test_throw("Move Assign");
}
return *this;
}
std::size_t operator()(int x) const
@@ -68,54 +93,109 @@ namespace noexcept_tests {
test_throw("Operator");
return static_cast<base const&>(*this)(x);
}
friend void swap(hash_nothrow&, hash_nothrow&)
BOOST_NOEXCEPT_IF(nothrow_swap)
{
if (!nothrow_swap) {
test_throw("Swap");
}
}
};
class equal_to_nothrow_move : std::equal_to<int>
{
BOOST_COPYABLE_AND_MOVABLE(equal_to_nothrow_move)
typedef hash_nothrow<true, false, false> hash_nothrow_move_construct;
typedef hash_nothrow<false, true, false> hash_nothrow_move_assign;
typedef hash_nothrow<false, false, true> hash_nothrow_swap;
typedef std::equal_to<int> base;
template <bool nothrow_move_construct, bool nothrow_move_assign,
bool nothrow_swap>
class equal_to_nothrow
{
BOOST_COPYABLE_AND_MOVABLE(equal_to_nothrow)
typedef boost::hash<int> base;
public:
equal_to_nothrow_move(BOOST_RV_REF(equal_to_nothrow_move)) BOOST_NOEXCEPT {}
equal_to_nothrow_move() { test_throw("Constructor"); }
equal_to_nothrow_move(equal_to_nothrow_move const&) { test_throw("Copy"); }
equal_to_nothrow_move& operator=(
BOOST_COPY_ASSIGN_REF(equal_to_nothrow_move))
equal_to_nothrow(BOOST_RV_REF(equal_to_nothrow))
BOOST_NOEXCEPT_IF(nothrow_move_construct)
{
if (!nothrow_move_construct) {
test_throw("Move Constructor");
}
}
equal_to_nothrow() { test_throw("Constructor"); }
equal_to_nothrow(equal_to_nothrow const&) { test_throw("Copy"); }
equal_to_nothrow& operator=(BOOST_COPY_ASSIGN_REF(equal_to_nothrow))
{
test_throw("Assign");
return *this;
}
equal_to_nothrow_move& operator=(BOOST_RV_REF(equal_to_nothrow_move))
equal_to_nothrow& operator=(BOOST_RV_REF(equal_to_nothrow))
BOOST_NOEXCEPT_IF(nothrow_move_assign)
{
test_throw("Move Assign");
if (!nothrow_move_assign) {
test_throw("Move Assign");
}
return *this;
}
std::size_t operator()(int x, int y) const
{
test_throw("Operator");
return static_cast<base const&>(*this)(x, y);
return x == y;
}
friend void swap(equal_to_nothrow&, equal_to_nothrow&)
BOOST_NOEXCEPT_IF(nothrow_swap)
{
if (!nothrow_swap) {
test_throw("Swap");
}
}
};
typedef equal_to_nothrow<true, false, false> equal_to_nothrow_move_construct;
typedef equal_to_nothrow<false, true, false> equal_to_nothrow_move_assign;
typedef equal_to_nothrow<false, false, true> equal_to_nothrow_swap;
bool have_is_nothrow_move = false;
bool have_is_nothrow_move_assign = false;
bool have_is_nothrow_swap = false;
UNORDERED_AUTO_TEST (check_is_nothrow_move) {
BOOST_TEST(
!boost::is_nothrow_move_constructible<hash_possible_exception>::value);
have_is_nothrow_move =
boost::is_nothrow_move_constructible<hash_nothrow_move>::value;
BOOST_TEST(
!boost::is_nothrow_move_assignable<hash_possible_exception>::value);
BOOST_TEST(!boost::is_nothrow_swappable<hash_possible_exception>::value);
BOOST_TEST((!boost::is_nothrow_move_constructible<
equal_to_nothrow<false, false, false> >::value));
BOOST_TEST((!boost::is_nothrow_move_assignable<
equal_to_nothrow<false, false, false> >::value));
BOOST_TEST((!boost::is_nothrow_swappable<
equal_to_nothrow<false, false, false> >::value));
// Copied from boost::is_nothrow_move_constructible implementation
// to make sure this does actually detect it when expected.
//
// The type trait is also available when BOOST_IS_NOTHROW_MOVE_CONSTRUCT
// is defined (for some versions of Visual C++?) but detects 'throw()',
// not noexcept.
have_is_nothrow_move =
boost::is_nothrow_move_constructible<hash_nothrow_move_construct>::value;
have_is_nothrow_move_assign =
boost::is_nothrow_move_assignable<hash_nothrow_move_assign>::value;
have_is_nothrow_swap =
boost::is_nothrow_swappable<hash_nothrow_swap>::value;
// Check that the traits work when expected.
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) && \
!BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800)
BOOST_TEST(have_is_nothrow_move);
BOOST_TEST(have_is_nothrow_move_assign);
#endif
#if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_NOEXCEPT) && \
!defined(BOOST_NO_CXX11_DECLTYPE) && \
!defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
BOOST_TEST(have_is_nothrow_swap);
#endif
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< "have_is_nothrow_move: " << have_is_nothrow_move << std::endl
<< "have_is_nothrow_swap: " << have_is_nothrow_swap << std::endl;
}
UNORDERED_AUTO_TEST (test_noexcept) {
@@ -137,32 +217,104 @@ namespace noexcept_tests {
boost::hash<int>, equal_to_possible_exception> >::value));
}
UNORDERED_AUTO_TEST (test_no_throw_when_noexcept) {
typedef boost::unordered_set<int, hash_nothrow_move, equal_to_nothrow_move>
UNORDERED_AUTO_TEST (test_nothrow_move_when_noexcept) {
typedef boost::unordered_set<int, hash_nothrow_move_construct,
equal_to_nothrow_move_construct>
throwing_set;
if (have_is_nothrow_move) {
BOOST_TEST(boost::is_nothrow_move_constructible<throwing_set>::value);
throwing_test_exception = false;
throwing_set x1;
x1.insert(10);
x1.insert(50);
try {
throwing_test_exception = true;
throwing_set x2 = boost::move(x1);
BOOST_TEST(x2.size() == 2);
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
} catch (test_exception) {
BOOST_TEST(false);
}
throwing_test_exception = false;
}
throwing_test_exception = false;
throwing_set x1;
x1.insert(10);
x1.insert(50);
try {
throwing_test_exception = true;
throwing_set x2 = boost::move(x1);
BOOST_TEST(x2.size() == 2);
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
BOOST_TEST(have_is_nothrow_move);
} catch (test_exception) {
BOOST_TEST(!have_is_nothrow_move);
}
throwing_test_exception = false;
}
UNORDERED_AUTO_TEST (test_nothrow_move_assign_when_noexcept) {
typedef boost::unordered_set<int, hash_nothrow_move_assign,
equal_to_nothrow_move_assign>
throwing_set;
if (have_is_nothrow_move_assign) {
BOOST_TEST(boost::is_nothrow_move_assignable<throwing_set>::value);
}
throwing_test_exception = false;
throwing_set x1;
throwing_set x2;
x1.insert(10);
x1.insert(50);
for (int i = 0; i < 100; ++i) {
x2.insert(i);
}
try {
throwing_test_exception = true;
x2 = boost::move(x1);
BOOST_TEST(x2.size() == 2);
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
BOOST_TEST(have_is_nothrow_move_assign);
} catch (test_exception) {
BOOST_TEST(!have_is_nothrow_move_assign);
}
throwing_test_exception = false;
}
UNORDERED_AUTO_TEST (test_nothrow_swap_when_noexcept) {
typedef boost::unordered_set<int, hash_nothrow_swap, equal_to_nothrow_swap>
throwing_set;
if (have_is_nothrow_swap) {
BOOST_TEST(boost::is_nothrow_swappable<throwing_set>::value);
}
throwing_test_exception = false;
throwing_set x1;
throwing_set x2;
x1.insert(10);
x1.insert(50);
for (int i = 0; i < 100; ++i) {
x2.insert(i);
}
try {
throwing_test_exception = true;
x1.swap(x2);
BOOST_TEST(x1.size() == 100);
BOOST_TEST(x2.size() == 2);
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
BOOST_TEST(have_is_nothrow_swap);
} catch (test_exception) {
BOOST_TEST(!have_is_nothrow_swap);
}
throwing_test_exception = false;
}
}
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
RUN_TESTS()

View File

@@ -20,8 +20,7 @@ namespace rehash_tests {
test::seed_t initialize_seed(2974);
template <class X>
bool postcondition(X const& x, BOOST_DEDUCED_TYPENAME X::size_type n)
template <class X> bool postcondition(X const& x, typename X::size_type n)
{
return static_cast<double>(x.bucket_count()) >=
static_cast<double>(x.size()) / x.max_load_factor() &&

View File

@@ -73,7 +73,7 @@ template <class X> void simple_test(X const& a)
}
{
BOOST_TEST(a.size() == static_cast<BOOST_DEDUCED_TYPENAME X::size_type>(
BOOST_TEST(a.size() == static_cast<typename X::size_type>(
std::distance(a.begin(), a.end())));
}

View File

@@ -78,9 +78,9 @@ namespace swap_tests {
{
swap_tests1(ptr, generator);
typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
typedef typename X::hasher hasher;
typedef typename X::key_equal key_equal;
typedef typename X::allocator_type allocator_type;
{
test::check_instances check_;

View File

@@ -177,7 +177,7 @@ namespace unnecessary_copy_tests {
template <class T> void unnecessary_copy_insert_test(T*)
{
T x;
BOOST_DEDUCED_TYPENAME T::value_type a;
typename T::value_type a;
reset();
x.insert(a);
COPY_COUNT(1);
@@ -187,13 +187,13 @@ namespace unnecessary_copy_tests {
template <class T> void unnecessary_copy_insert_rvalue_set_test(T*)
{
T x;
BOOST_DEDUCED_TYPENAME T::value_type a;
typename T::value_type a;
reset();
x.insert(boost::move(a));
COPY_COUNT(0);
MOVE_COUNT(1);
BOOST_DEDUCED_TYPENAME T::value_type a2;
typename T::value_type a2;
reset();
x.insert(boost::move(a));
COPY_COUNT(0);
@@ -207,7 +207,7 @@ namespace unnecessary_copy_tests {
// construct_from_args.
T x;
BOOST_DEDUCED_TYPENAME T::value_type a;
typename T::value_type a;
reset();
x.insert(boost::move(a));
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@@ -218,7 +218,7 @@ namespace unnecessary_copy_tests {
MOVE_COUNT(1);
#endif
BOOST_DEDUCED_TYPENAME T::value_type a2;
typename T::value_type a2;
reset();
x.insert(boost::move(a));
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@@ -243,7 +243,7 @@ namespace unnecessary_copy_tests {
{
reset();
T x;
BOOST_DEDUCED_TYPENAME T::value_type a;
typename T::value_type a;
COPY_COUNT(1);
x.emplace(a);
COPY_COUNT(2);
@@ -253,7 +253,7 @@ namespace unnecessary_copy_tests {
{
reset();
T x;
x.emplace(source<BOOST_DEDUCED_TYPENAME T::value_type>());
x.emplace(source<typename T::value_type>());
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
COPY_COUNT(1);
#else
@@ -271,7 +271,7 @@ namespace unnecessary_copy_tests {
{
reset();
T x;
BOOST_DEDUCED_TYPENAME T::value_type a;
typename T::value_type a;
COPY_COUNT(1);
MOVE_COUNT(0);
x.emplace(std::move(a));
@@ -287,7 +287,7 @@ namespace unnecessary_copy_tests {
{
reset();
T x;
BOOST_DEDUCED_TYPENAME T::value_type a;
typename T::value_type a;
COPY_COUNT(1);
MOVE_COUNT_EXTRA(0, 1);
x.emplace(boost::move(a));
@@ -308,7 +308,7 @@ namespace unnecessary_copy_tests {
{
reset();
T x;
BOOST_DEDUCED_TYPENAME T::value_type a;
typename T::value_type a;
COPY_COUNT(1);
MOVE_COUNT(0);
x.emplace(boost::move(a));
@@ -325,7 +325,7 @@ namespace unnecessary_copy_tests {
T x;
COPY_COUNT(0);
MOVE_COUNT(0);
BOOST_DEDUCED_TYPENAME T::value_type a;
typename T::value_type a;
COPY_COUNT(1);
MOVE_COUNT_EXTRA(0, 1);
x.emplace(boost::move(a));