mirror of
https://github.com/boostorg/unordered.git
synced 2025-10-17 18:05:25 +02:00
Fix exception handling in rehash_impl
And improve tests so they will catch the error, and other similar errors.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "../helpers/count.hpp"
|
||||
#include "../helpers/fwd.hpp"
|
||||
#include "../helpers/memory.hpp"
|
||||
#include "../objects/fwd.hpp"
|
||||
#include <boost/limits.hpp>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
@@ -311,6 +312,55 @@ class equal_to
|
||||
}
|
||||
};
|
||||
|
||||
class less
|
||||
{
|
||||
int tag_;
|
||||
|
||||
public:
|
||||
less(int t = 0) : tag_(t) {}
|
||||
|
||||
less(less const& x) : tag_(x.tag_) {}
|
||||
|
||||
bool operator()(object const& x1, object const& x2) const
|
||||
{
|
||||
return less_impl(x1, x2);
|
||||
}
|
||||
|
||||
bool operator()(std::pair<object, object> const& x1,
|
||||
std::pair<object, object> const& x2) const
|
||||
{
|
||||
if (less_impl(x1.first, x2.first)) {
|
||||
return true;
|
||||
}
|
||||
if (!less_impl(x1.first, x2.first)) {
|
||||
return false;
|
||||
}
|
||||
return less_impl(x1.second, x2.second);
|
||||
}
|
||||
|
||||
bool less_impl(object const& x1, object const& x2) const
|
||||
{
|
||||
switch (tag_) {
|
||||
case 1:
|
||||
return x1.tag1_ < x2.tag1_;
|
||||
case 2:
|
||||
return x1.tag2_ < x2.tag2_;
|
||||
default:
|
||||
return x1 < x2;
|
||||
}
|
||||
}
|
||||
|
||||
friend bool operator==(less const& x1, less const& x2)
|
||||
{
|
||||
return x1.tag_ == x2.tag_;
|
||||
}
|
||||
|
||||
friend bool operator!=(less const& x1, less const& x2)
|
||||
{
|
||||
return x1.tag_ != x2.tag_;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> class allocator
|
||||
{
|
||||
public:
|
||||
@@ -672,6 +722,14 @@ inline bool operator!=(allocator2<T> const& x, allocator2<T> const& y)
|
||||
}
|
||||
}
|
||||
|
||||
namespace test {
|
||||
template <typename X> struct equals_to_compare;
|
||||
template <> struct equals_to_compare<test::exception::equal_to>
|
||||
{
|
||||
typedef test::exception::less type;
|
||||
};
|
||||
}
|
||||
|
||||
// Workaround for ADL deficient compilers
|
||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||
namespace test {
|
||||
|
Reference in New Issue
Block a user