2006-05-21 17:14:11 +00:00
|
|
|
|
2009-03-09 20:56:23 +00:00
|
|
|
// Copyright 2006-2009 Daniel James.
|
2006-07-01 22:31:26 +00:00
|
|
|
// 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)
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2008-01-13 16:19:26 +00:00
|
|
|
#if !defined(BOOST_UNORDERED_EXCEPTION_TEST_OBJECTS_HEADER)
|
|
|
|
#define BOOST_UNORDERED_EXCEPTION_TEST_OBJECTS_HEADER
|
|
|
|
|
|
|
|
#include "../helpers/exception_test.hpp"
|
2008-01-12 14:43:40 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
#include "../helpers/count.hpp"
|
|
|
|
#include "../helpers/fwd.hpp"
|
|
|
|
#include "../helpers/memory.hpp"
|
|
|
|
#include <boost/limits.hpp>
|
2006-05-21 17:14:11 +00:00
|
|
|
#include <cstddef>
|
2008-01-12 14:43:40 +00:00
|
|
|
#include <iostream>
|
2008-01-20 17:37:21 +00:00
|
|
|
#include <new>
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
namespace test {
|
|
|
|
namespace exception {
|
|
|
|
class object;
|
|
|
|
class hash;
|
|
|
|
class equal_to;
|
|
|
|
template <class T> class allocator;
|
|
|
|
object generate(object const*, random_generator);
|
|
|
|
std::pair<object, object> generate(
|
|
|
|
std::pair<object, object> const*, random_generator);
|
|
|
|
|
|
|
|
struct true_type
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
enum
|
2011-08-11 21:18:43 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
value = true
|
2011-08-11 21:18:43 +00:00
|
|
|
};
|
2017-02-19 13:05:17 +00:00
|
|
|
};
|
2011-08-11 21:18:43 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
struct false_type
|
|
|
|
{
|
|
|
|
enum
|
2011-08-11 21:18:43 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
value = false
|
2011-08-11 21:18:43 +00:00
|
|
|
};
|
2017-02-19 13:05:17 +00:00
|
|
|
};
|
2011-08-11 21:18:43 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
class object : private counted_object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int tag1_, tag2_;
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
explicit object() : tag1_(0), tag2_(0)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(object::object())
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock object default constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
explicit object(int t1, int t2 = 0) : tag1_(t1), tag2_(t2)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(object::object(int))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock object constructor by value.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
object(object const& x) : counted_object(x), tag1_(x.tag1_), tag2_(x.tag2_)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(object::object(object))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock object copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
~object()
|
|
|
|
{
|
|
|
|
tag1_ = -1;
|
|
|
|
tag2_ = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
object& operator=(object const& x)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(object::operator=(object))
|
|
|
|
{
|
|
|
|
tag1_ = x.tag1_;
|
|
|
|
UNORDERED_EPOINT("Mock object assign operator 1.");
|
|
|
|
tag2_ = x.tag2_;
|
|
|
|
// UNORDERED_EPOINT("Mock object assign operator 2.");
|
2006-10-31 22:19:26 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2006-10-31 22:19:26 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
friend bool operator==(object const& x1, object const& x2)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(operator==(object, object))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock object equality operator.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
return x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_;
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
friend bool operator!=(object const& x1, object const& x2)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(operator!=(object, object))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock object inequality operator.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
return !(x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_);
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// None of the last few functions are used by the unordered associative
|
|
|
|
// containers - so there aren't any exception points.
|
|
|
|
friend bool operator<(object const& x1, object const& x2)
|
|
|
|
{
|
|
|
|
return x1.tag1_ < x2.tag1_ ||
|
|
|
|
(x1.tag1_ == x2.tag1_ && x1.tag2_ < x2.tag2_);
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
friend object generate(object const*, random_generator g)
|
|
|
|
{
|
|
|
|
int* x = 0;
|
|
|
|
return object(::test::generate(x, g), ::test::generate(x, g));
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
friend std::ostream& operator<<(std::ostream& out, object const& o)
|
|
|
|
{
|
|
|
|
return out << "(" << o.tag1_ << "," << o.tag2_ << ")";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-23 20:10:40 +00:00
|
|
|
std::pair<object, object> generate(
|
|
|
|
std::pair<object, object> const*, random_generator g)
|
|
|
|
{
|
|
|
|
int* x = 0;
|
|
|
|
return std::make_pair(
|
|
|
|
object(::test::generate(x, g), ::test::generate(x, g)),
|
|
|
|
object(::test::generate(x, g), ::test::generate(x, g)));
|
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
class hash
|
|
|
|
{
|
|
|
|
int tag_;
|
2017-01-01 18:35:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
public:
|
|
|
|
hash(int t = 0) : tag_(t)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(hash::object())
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock hash default constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
hash(hash const& x) : tag_(x.tag_)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_SCOPE(hash::hash(hash))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock hash copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
hash& operator=(hash const& x)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(hash::operator=(hash))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock hash assign operator 1.");
|
|
|
|
tag_ = x.tag_;
|
|
|
|
UNORDERED_EPOINT("Mock hash assign operator 2.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
std::size_t operator()(object const& x) const
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(hash::operator()(object))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock hash function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
return hash_impl(x);
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
std::size_t operator()(std::pair<object, object> const& x) const
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(hash::operator()(std::pair<object, object>))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock hash pair function.");
|
2017-01-01 18:35:50 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
return hash_impl(x.first) * 193ul + hash_impl(x.second) * 97ul + 29ul;
|
|
|
|
}
|
2017-01-01 18:35:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
std::size_t hash_impl(object const& x) const
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
switch (tag_) {
|
|
|
|
case 1:
|
|
|
|
result = x.tag1_;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
result = x.tag2_;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result = x.tag1_ + x.tag2_;
|
|
|
|
}
|
|
|
|
return static_cast<std::size_t>(result);
|
|
|
|
}
|
2017-01-01 18:35:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
friend bool operator==(hash const& x1, hash const& x2)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(operator==(hash, hash))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock hash equality function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return x1.tag_ == x2.tag_;
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
friend bool operator!=(hash const& x1, hash const& x2)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(hash::operator!=(hash, hash))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock hash inequality function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return x1.tag_ != x2.tag_;
|
|
|
|
}
|
|
|
|
};
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
class equal_to
|
|
|
|
{
|
|
|
|
int tag_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
equal_to(int t = 0) : tag_(t)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(equal_to::equal_to())
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock equal_to default constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
equal_to(equal_to const& x) : tag_(x.tag_)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_SCOPE(equal_to::equal_to(equal_to))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock equal_to copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
equal_to& operator=(equal_to const& x)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(equal_to::operator=(equal_to))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock equal_to assign operator 1.");
|
|
|
|
tag_ = x.tag_;
|
|
|
|
UNORDERED_EPOINT("Mock equal_to assign operator 2.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
bool operator()(object const& x1, object const& x2) const
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(equal_to::operator()(object, object))
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock equal_to function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
return equal_impl(x1, x2);
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
bool operator()(std::pair<object, object> const& x1,
|
|
|
|
std::pair<object, object> const& x2) const
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(equal_to::operator()(
|
|
|
|
std::pair<object, object>, std::pair<object, object>))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock equal_to function.");
|
2017-01-01 18:35:50 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
return equal_impl(x1.first, x2.first) &&
|
|
|
|
equal_impl(x1.second, x2.second);
|
|
|
|
}
|
2017-01-01 18:35:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
bool equal_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;
|
2017-01-01 18:35:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2017-01-01 18:35:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
friend bool operator==(equal_to const& x1, equal_to const& x2)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(operator==(equal_to, equal_to))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock equal_to equality function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return x1.tag_ == x2.tag_;
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
friend bool operator!=(equal_to const& x1, equal_to const& x2)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(operator!=(equal_to, equal_to))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock equal_to inequality function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return x1.tag_ != x2.tag_;
|
|
|
|
}
|
|
|
|
};
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class T> class allocator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int tag_;
|
|
|
|
typedef std::size_t size_type;
|
|
|
|
typedef std::ptrdiff_t difference_type;
|
|
|
|
typedef T* pointer;
|
|
|
|
typedef T const* const_pointer;
|
|
|
|
typedef T& reference;
|
|
|
|
typedef T const& const_reference;
|
|
|
|
typedef T value_type;
|
|
|
|
|
|
|
|
template <class U> struct rebind
|
|
|
|
{
|
|
|
|
typedef allocator<U> other;
|
2006-05-21 17:14:11 +00:00
|
|
|
};
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
explicit allocator(int t = 0) : tag_(t)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_SCOPE(allocator::allocator())
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock allocator default constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.allocator_ref();
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class Y> allocator(allocator<Y> const& x) : tag_(x.tag_)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator::allocator())
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock allocator template copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.allocator_ref();
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
allocator(allocator const& x) : tag_(x.tag_)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator::allocator())
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock allocator copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.allocator_ref();
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
~allocator() { test::detail::tracker.allocator_unref(); }
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
allocator& operator=(allocator const& x)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator::allocator())
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator assignment operator.");
|
|
|
|
tag_ = x.tag_;
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// If address throws, then it can't be used in erase or the
|
|
|
|
// destructor, which is very limiting. I need to check up on
|
|
|
|
// this.
|
2006-10-31 22:19:26 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
pointer address(reference r)
|
|
|
|
{
|
|
|
|
// UNORDERED_SCOPE(allocator::address(reference)) {
|
|
|
|
// UNORDERED_EPOINT("Mock allocator address function.");
|
|
|
|
//}
|
|
|
|
return pointer(&r);
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
const_pointer address(const_reference r)
|
|
|
|
{
|
|
|
|
// UNORDERED_SCOPE(allocator::address(const_reference)) {
|
|
|
|
// UNORDERED_EPOINT("Mock allocator const address function.");
|
|
|
|
//}
|
|
|
|
return const_pointer(&r);
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
pointer allocate(size_type n)
|
|
|
|
{
|
|
|
|
T* ptr = 0;
|
|
|
|
UNORDERED_SCOPE(allocator::allocate(size_type))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator allocate function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
using namespace std;
|
|
|
|
ptr = (T*)malloc(n * sizeof(T));
|
|
|
|
if (!ptr)
|
|
|
|
throw std::bad_alloc();
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
|
|
|
|
return pointer(ptr);
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
pointer allocate(size_type n, void const*)
|
|
|
|
{
|
|
|
|
T* ptr = 0;
|
|
|
|
UNORDERED_SCOPE(allocator::allocate(size_type, const_pointer))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator allocate function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
using namespace std;
|
|
|
|
ptr = (T*)malloc(n * sizeof(T));
|
|
|
|
if (!ptr)
|
|
|
|
throw std::bad_alloc();
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
|
|
|
|
return pointer(ptr);
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
|
|
|
|
}
|
|
|
|
|
|
|
|
void deallocate(pointer p, size_type n)
|
|
|
|
{
|
|
|
|
//::operator delete((void*) p);
|
|
|
|
if (p) {
|
|
|
|
test::detail::tracker.track_deallocate(
|
|
|
|
(void*)p, n, sizeof(T), tag_);
|
|
|
|
using namespace std;
|
|
|
|
free(p);
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
void construct(pointer p, T const& t)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator::construct(T*, T))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator construct function.");
|
|
|
|
new (p) T(t);
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.track_construct((void*)p, sizeof(T), tag_);
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2012-11-26 17:47:12 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator::construct(pointer, BOOST_FWD_REF(Args)...))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator construct function.");
|
|
|
|
new (p) T(boost::forward<Args>(args)...);
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.track_construct((void*)p, sizeof(T), tag_);
|
|
|
|
}
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
#endif
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
void destroy(T* p)
|
|
|
|
{
|
|
|
|
test::detail::tracker.track_destroy((void*)p, sizeof(T), tag_);
|
|
|
|
p->~T();
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
size_type max_size() const
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator::construct(pointer, T))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator max_size function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return (std::numeric_limits<std::size_t>::max)();
|
|
|
|
}
|
2011-08-11 21:18:43 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
typedef true_type propagate_on_container_copy_assignment;
|
|
|
|
typedef true_type propagate_on_container_move_assignment;
|
|
|
|
typedef true_type propagate_on_container_swap;
|
|
|
|
};
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class T> void swap(allocator<T>& x, allocator<T>& y)
|
|
|
|
{
|
|
|
|
std::swap(x.tag_, y.tag_);
|
|
|
|
}
|
2007-07-17 23:17:21 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// It's pretty much impossible to write a compliant swap when these
|
|
|
|
// two can throw. So they don't.
|
2006-10-31 22:19:26 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class T>
|
|
|
|
inline bool operator==(allocator<T> const& x, allocator<T> const& y)
|
|
|
|
{
|
|
|
|
// UNORDERED_SCOPE(operator==(allocator, allocator)) {
|
|
|
|
// UNORDERED_EPOINT("Mock allocator equality operator.");
|
|
|
|
//}
|
|
|
|
return x.tag_ == y.tag_;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
inline bool operator!=(allocator<T> const& x, allocator<T> const& y)
|
|
|
|
{
|
|
|
|
// UNORDERED_SCOPE(operator!=(allocator, allocator)) {
|
|
|
|
// UNORDERED_EPOINT("Mock allocator inequality operator.");
|
|
|
|
//}
|
|
|
|
return x.tag_ != y.tag_;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T> class allocator2
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int tag_;
|
|
|
|
typedef std::size_t size_type;
|
|
|
|
typedef std::ptrdiff_t difference_type;
|
|
|
|
typedef T* pointer;
|
|
|
|
typedef T const* const_pointer;
|
|
|
|
typedef T& reference;
|
|
|
|
typedef T const& const_reference;
|
|
|
|
typedef T value_type;
|
|
|
|
|
|
|
|
template <class U> struct rebind
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
typedef allocator2<U> other;
|
|
|
|
};
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
explicit allocator2(int t = 0) : tag_(t)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_SCOPE(allocator2::allocator2())
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator2 default constructor.");
|
|
|
|
}
|
|
|
|
test::detail::tracker.allocator_ref();
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
allocator2(allocator<T> const& x) : tag_(x.tag_)
|
2012-08-25 21:54:50 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_SCOPE(allocator2::allocator2())
|
2012-08-25 21:54:50 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock allocator2 constructor from allocator.");
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.allocator_ref();
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class Y> allocator2(allocator2<Y> const& x) : tag_(x.tag_)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator2::allocator2())
|
2012-08-25 21:54:50 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock allocator2 template copy constructor.");
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.allocator_ref();
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
allocator2(allocator2 const& x) : tag_(x.tag_)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator2::allocator2())
|
2012-08-25 21:54:50 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock allocator2 copy constructor.");
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.allocator_ref();
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
~allocator2() { test::detail::tracker.allocator_unref(); }
|
|
|
|
|
|
|
|
allocator2& operator=(allocator2 const& x)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator2::allocator2())
|
2012-08-25 21:54:50 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock allocator2 assignment operator.");
|
|
|
|
tag_ = x.tag_;
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// If address throws, then it can't be used in erase or the
|
|
|
|
// destructor, which is very limiting. I need to check up on
|
|
|
|
// this.
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
pointer address(reference r)
|
|
|
|
{
|
|
|
|
// UNORDERED_SCOPE(allocator2::address(reference)) {
|
|
|
|
// UNORDERED_EPOINT("Mock allocator2 address function.");
|
|
|
|
//}
|
|
|
|
return pointer(&r);
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
const_pointer address(const_reference r)
|
|
|
|
{
|
|
|
|
// UNORDERED_SCOPE(allocator2::address(const_reference)) {
|
|
|
|
// UNORDERED_EPOINT("Mock allocator2 const address function.");
|
|
|
|
//}
|
|
|
|
return const_pointer(&r);
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
pointer allocate(size_type n)
|
|
|
|
{
|
|
|
|
T* ptr = 0;
|
|
|
|
UNORDERED_SCOPE(allocator2::allocate(size_type))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator2 allocate function.");
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
using namespace std;
|
|
|
|
ptr = (T*)malloc(n * sizeof(T));
|
|
|
|
if (!ptr)
|
|
|
|
throw std::bad_alloc();
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
|
|
|
|
return pointer(ptr);
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
pointer allocate(size_type n, void const*)
|
|
|
|
{
|
|
|
|
T* ptr = 0;
|
|
|
|
UNORDERED_SCOPE(allocator2::allocate(size_type, const_pointer))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator2 allocate function.");
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
using namespace std;
|
|
|
|
ptr = (T*)malloc(n * sizeof(T));
|
|
|
|
if (!ptr)
|
|
|
|
throw std::bad_alloc();
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
|
|
|
|
return pointer(ptr);
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
void deallocate(pointer p, size_type n)
|
|
|
|
{
|
|
|
|
//::operator delete((void*) p);
|
|
|
|
if (p) {
|
|
|
|
test::detail::tracker.track_deallocate(
|
|
|
|
(void*)p, n, sizeof(T), tag_);
|
|
|
|
using namespace std;
|
|
|
|
free(p);
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
void construct(pointer p, T const& t)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator2::construct(T*, T))
|
2012-08-25 21:54:50 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
UNORDERED_EPOINT("Mock allocator2 construct function.");
|
|
|
|
new (p) T(t);
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.track_construct((void*)p, sizeof(T), tag_);
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2012-11-26 17:47:12 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args)
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator2::construct(pointer, BOOST_FWD_REF(Args)...))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator2 construct function.");
|
|
|
|
new (p) T(boost::forward<Args>(args)...);
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
test::detail::tracker.track_construct((void*)p, sizeof(T), tag_);
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
#endif
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
void destroy(T* p)
|
|
|
|
{
|
|
|
|
test::detail::tracker.track_destroy((void*)p, sizeof(T), tag_);
|
|
|
|
p->~T();
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
size_type max_size() const
|
|
|
|
{
|
|
|
|
UNORDERED_SCOPE(allocator2::construct(pointer, T))
|
|
|
|
{
|
|
|
|
UNORDERED_EPOINT("Mock allocator2 max_size function.");
|
2012-08-25 21:54:50 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
return (std::numeric_limits<std::size_t>::max)();
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
typedef false_type propagate_on_container_copy_assignment;
|
|
|
|
typedef false_type propagate_on_container_move_assignment;
|
|
|
|
typedef false_type propagate_on_container_swap;
|
|
|
|
};
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class T> void swap(allocator2<T>& x, allocator2<T>& y)
|
|
|
|
{
|
|
|
|
std::swap(x.tag_, y.tag_);
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// It's pretty much impossible to write a compliant swap when these
|
|
|
|
// two can throw. So they don't.
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class T>
|
|
|
|
inline bool operator==(allocator2<T> const& x, allocator2<T> const& y)
|
|
|
|
{
|
|
|
|
// UNORDERED_SCOPE(operator==(allocator2, allocator2)) {
|
|
|
|
// UNORDERED_EPOINT("Mock allocator2 equality operator.");
|
|
|
|
//}
|
|
|
|
return x.tag_ == y.tag_;
|
|
|
|
}
|
2012-08-25 21:54:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
template <class T>
|
|
|
|
inline bool operator!=(allocator2<T> const& x, allocator2<T> const& y)
|
|
|
|
{
|
|
|
|
// UNORDERED_SCOPE(operator!=(allocator2, allocator2)) {
|
|
|
|
// UNORDERED_EPOINT("Mock allocator2 inequality operator.");
|
|
|
|
//}
|
|
|
|
return x.tag_ != y.tag_;
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-12 14:43:40 +00:00
|
|
|
// Workaround for ADL deficient compilers
|
|
|
|
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
2017-02-19 13:05:17 +00:00
|
|
|
namespace test {
|
|
|
|
test::exception::object generate(
|
|
|
|
test::exception::object const* x, random_generator g)
|
2008-01-12 14:43:40 +00:00
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
return test::exception::generate(x, g);
|
|
|
|
}
|
2017-01-01 18:35:50 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
std::pair<test::exception::object, test::exception::object> generate(
|
|
|
|
std::pair<test::exception::object, test::exception::object> const* x,
|
|
|
|
random_generator g)
|
|
|
|
{
|
|
|
|
return test::exception::generate(x, g);
|
|
|
|
}
|
2008-01-12 14:43:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-05-21 17:14:11 +00:00
|
|
|
#endif
|