2006-05-21 17:14:11 +00:00
|
|
|
|
Merge hash and unordered changes.
Remove deprecated headers, move hash_fwd.hpp into hash subdirectory. And
several minor internal changes.
Mostly minor internal details.
Merged revisions 51262-51263,51407-51409,51504-51505,51644-51646,51667 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r51262 | danieljames | 2009-02-15 19:32:04 +0000 (Sun, 15 Feb 2009) | 1 line
Use the new 'boost:' links for the hash, unordered and quickbook documentation.
........
r51263 | danieljames | 2009-02-15 19:32:19 +0000 (Sun, 15 Feb 2009) | 2 lines
Don't copy images for the standalone hash and unordered documentation, was only
really required before the libraries were integrated into boost.
........
r51407 | danieljames | 2009-02-22 23:49:51 +0000 (Sun, 22 Feb 2009) | 1 line
Fix the hash dirname.
........
r51408 | danieljames | 2009-02-22 23:50:04 +0000 (Sun, 22 Feb 2009) | 1 line
Make copy_buckets and move_buckets member functions - so that calling them is a bit simpler.
........
r51409 | danieljames | 2009-02-22 23:50:20 +0000 (Sun, 22 Feb 2009) | 1 line
Move some of the data structure classes out of hash table data.
........
r51504 | danieljames | 2009-03-01 14:15:09 +0000 (Sun, 01 Mar 2009) | 1 line
Add missing return for operator=.
........
r51505 | danieljames | 2009-03-01 14:15:39 +0000 (Sun, 01 Mar 2009) | 3 lines
Make the sort stable.
Doesn't really matter, but it might as well be.
........
r51644 | danieljames | 2009-03-08 09:44:51 +0000 (Sun, 08 Mar 2009) | 1 line
Detab.
........
r51645 | danieljames | 2009-03-08 09:45:11 +0000 (Sun, 08 Mar 2009) | 4 lines
Move hash_fwd into the hash subdirectory.
I should have done this in the last release. But now all of the hash
implementation is in the hash subdirectory.
........
r51646 | danieljames | 2009-03-08 09:45:30 +0000 (Sun, 08 Mar 2009) | 3 lines
Remove deprecated headers.
Fixes #2412.
........
r51667 | danieljames | 2009-03-09 20:56:23 +0000 (Mon, 09 Mar 2009) | 1 line
Update copyright dates in hash and unordered.
........
[SVN r51729]
2009-03-11 22:51:09 +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
|
|
|
|
2006-05-21 17:14:11 +00:00
|
|
|
#include <cstddef>
|
2008-01-12 14:43:40 +00:00
|
|
|
#include <iostream>
|
2006-05-21 17:14:11 +00:00
|
|
|
#include <boost/limits.hpp>
|
2008-01-20 17:37:21 +00:00
|
|
|
#include <new>
|
2006-05-21 17:14:11 +00:00
|
|
|
#include "../helpers/fwd.hpp"
|
2007-07-01 11:54:22 +00:00
|
|
|
#include "../helpers/allocator.hpp"
|
Merge from trunk. Fix some inspect errors, try to avoid instantiating the
equality operators when not required, and some bookkeeping.
................
r42539 | danieljames | 2008-01-06 17:48:11 +0000 (Sun, 06 Jan 2008) | 2 lines
Add the unordered library to the maintainers list.
................
r46579 | danieljames | 2008-06-21 16:32:11 +0100 (Sat, 21 Jun 2008) | 10 lines
Define unordered containers' friend functions outside of the class.
On some compilers, friend functions are being instantiated when the main class
is explicitly instantiated. This is slightly problematic because the equality
functions (which are an extension) put extra requirements on the types used. So
I'm going to try defining the functions outside of the class, in the hope that
they won't get instantiated. If someone wants non-member functions to be
instantiated, I think it's reasonable to expect them to explicitly instantiate
them, especially as compilers don't seem to be consistent about this.
................
r46587 | danieljames | 2008-06-21 20:58:39 +0100 (Sat, 21 Jun 2008) | 8 lines
Get the test to pass when pair's default constructor creates two instances of
the member classes.
With some standard libraries I was getting two copies of the object after
creating a default pair, probably because it was creating an instance for its
default parameter. So only test after creating the pair object - since it isn't
our concern how many instances that creates.
................
r46588 | danieljames | 2008-06-21 21:11:26 +0100 (Sat, 21 Jun 2008) | 1 line
Markup an expected failure for unordered.
................
r46594 | danieljames | 2008-06-21 23:02:15 +0100 (Sat, 21 Jun 2008) | 19 lines
Merge inspect fixes for the unordered library.
Merged revisions 46470-46592 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r46589 | danieljames | 2008-06-21 21:37:42 +0100 (Sat, 21 Jun 2008) | 2 lines
Fix some inspect errors (tabs and missing copyright/license).
................
r46591 | danieljames | 2008-06-21 21:47:51 +0100 (Sat, 21 Jun 2008) | 1 line
Move memory.hpp into the helpers subdirectory.
................
r46592 | danieljames | 2008-06-21 22:08:53 +0100 (Sat, 21 Jun 2008) | 1 line
Prevent inspect errors for unnamed namespaces in some of the test header files.
................
................
r46607 | danieljames | 2008-06-22 14:54:45 +0100 (Sun, 22 Jun 2008) | 9 lines
Extract the hash and equality functions from hash_table_data_*.
As these are extensions and add extra requirements to the container elements,
they shouldn't be part of hash_table_data_* so that they won't get instantiated
if an unordered container is explicitly instantiated.
Merged revisions 46594-46604 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r46608 | danieljames | 2008-06-22 16:00:02 +0100 (Sun, 22 Jun 2008) | 5 lines
Remove the svnmerge integration information for the unordered branch.
Now that the unordered library is moving towards release, the main development
version is in trunk. New features will be developed on a new branch.
................
[SVN r46629]
2008-06-23 17:44:53 +00:00
|
|
|
#include "../helpers/memory.hpp"
|
2006-05-21 17:14:11 +00:00
|
|
|
|
|
|
|
|
namespace test
|
|
|
|
|
{
|
|
|
|
|
namespace exception
|
|
|
|
|
{
|
2006-12-03 23:08:17 +00:00
|
|
|
namespace detail
|
|
|
|
|
{
|
2008-01-10 22:30:46 +00:00
|
|
|
namespace
|
2006-12-03 23:08:17 +00:00
|
|
|
{
|
2008-01-18 19:35:55 +00:00
|
|
|
test::detail::memory_tracker<test::malloc_allocator<int> > tracker;
|
2006-12-03 23:08:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-21 17:14:11 +00:00
|
|
|
class object;
|
|
|
|
|
class hash;
|
|
|
|
|
class equal_to;
|
|
|
|
|
template <class T> class allocator;
|
2008-01-20 18:55:57 +00:00
|
|
|
object generate(object const*);
|
2006-05-21 17:14:11 +00:00
|
|
|
|
|
|
|
|
class object
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int tag1_, tag2_;
|
|
|
|
|
|
|
|
|
|
explicit object() : tag1_(0), tag2_(0)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(object::object()) {
|
|
|
|
|
UNORDERED_EPOINT("Mock object default constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
explicit object(int t1, int t2 = 0) : tag1_(t1), tag2_(t2)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(object::object(int)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock object constructor by value.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object(object const& x)
|
|
|
|
|
: tag1_(x.tag1_), tag2_(x.tag2_)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(object::object(object)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock object copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-31 22:19:26 +00:00
|
|
|
~object() {
|
|
|
|
|
tag1_ = -1;
|
|
|
|
|
tag2_ = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-21 17:14:11 +00:00
|
|
|
object& operator=(object const& x)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(object::operator=(object)) {
|
2006-05-21 17:14:11 +00:00
|
|
|
tag1_ = x.tag1_;
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_EPOINT("Mock object assign operator 1.");
|
2006-05-21 17:14:11 +00:00
|
|
|
tag2_ = x.tag2_;
|
2008-01-13 16:19:26 +00:00
|
|
|
//UNORDERED_EPOINT("Mock object assign operator 2.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend bool operator==(object const& x1, object const& x2) {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(operator==(object, object)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock object equality operator.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend bool operator!=(object const& x1, object const& x2) {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(operator!=(object, object)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock object inequality operator.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !(x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend object generate(object const*) {
|
|
|
|
|
int* x = 0;
|
|
|
|
|
return object(::test::generate(x), ::test::generate(x));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend std::ostream& operator<<(std::ostream& out, object const& o)
|
|
|
|
|
{
|
|
|
|
|
return out<<"("<<o.tag1_<<","<<o.tag2_<<")";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class hash
|
|
|
|
|
{
|
|
|
|
|
int tag_;
|
|
|
|
|
public:
|
|
|
|
|
hash(int t = 0) : tag_(t)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(hash::object()) {
|
|
|
|
|
UNORDERED_EPOINT("Mock hash default constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hash(hash const& x)
|
|
|
|
|
: tag_(x.tag_)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(hash::hash(hash)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock hash copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hash& operator=(hash const& x)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(hash::operator=(hash)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock hash assign operator 1.");
|
2006-05-21 17:14:11 +00:00
|
|
|
tag_ = x.tag_;
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_EPOINT("Mock hash assign operator 2.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::size_t operator()(object const& x) const {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(hash::operator()(object)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock hash function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(tag_) {
|
|
|
|
|
case 1:
|
|
|
|
|
return x.tag1_;
|
|
|
|
|
case 2:
|
|
|
|
|
return x.tag2_;
|
|
|
|
|
default:
|
|
|
|
|
return x.tag1_ + x.tag2_;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend bool operator==(hash const& x1, hash const& x2) {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(operator==(hash, hash)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock hash equality function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return x1.tag_ == x2.tag_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend bool operator!=(hash const& x1, hash const& x2) {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(hash::operator!=(hash, hash)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock hash inequality function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return x1.tag_ != x2.tag_;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class equal_to
|
|
|
|
|
{
|
|
|
|
|
int tag_;
|
|
|
|
|
public:
|
|
|
|
|
equal_to(int t = 0) : tag_(t)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(equal_to::equal_to()) {
|
|
|
|
|
UNORDERED_EPOINT("Mock equal_to default constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
equal_to(equal_to const& x)
|
|
|
|
|
: tag_(x.tag_)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(equal_to::equal_to(equal_to)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock equal_to copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
equal_to& operator=(equal_to const& x)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(equal_to::operator=(equal_to)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock equal_to assign operator 1.");
|
2006-05-21 17:14:11 +00:00
|
|
|
tag_ = x.tag_;
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_EPOINT("Mock equal_to assign operator 2.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-31 22:19:26 +00:00
|
|
|
bool operator()(object const& x1, object const& x2) const {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(equal_to::operator()(object, object)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock equal_to function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(tag_) {
|
|
|
|
|
case 1:
|
|
|
|
|
return x1.tag1_ == x2.tag1_;
|
|
|
|
|
case 2:
|
|
|
|
|
return x1.tag2_ == x2.tag2_;
|
|
|
|
|
default:
|
|
|
|
|
return x1 == x2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend bool operator==(equal_to const& x1, equal_to const& x2) {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(operator==(equal_to, equal_to)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock equal_to equality function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return x1.tag_ == x2.tag_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend bool operator!=(equal_to const& x1, equal_to const& x2) {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(operator!=(equal_to, equal_to)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock equal_to inequality function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return x1.tag_ != x2.tag_;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
|
class allocator
|
|
|
|
|
{
|
|
|
|
|
public:
|
2006-12-03 23:08:17 +00:00
|
|
|
int tag_;
|
2006-05-21 17:14:11 +00:00
|
|
|
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-12-03 23:08:17 +00:00
|
|
|
explicit allocator(int t = 0) : tag_(t)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(allocator::allocator()) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator default constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.allocator_ref();
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-03 23:08:17 +00:00
|
|
|
template <class Y> allocator(allocator<Y> const& x) : tag_(x.tag_)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(allocator::allocator()) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator template copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.allocator_ref();
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-03 23:08:17 +00:00
|
|
|
allocator(allocator const& x) : tag_(x.tag_)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(allocator::allocator()) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator copy constructor.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.allocator_ref();
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-03 23:08:17 +00:00
|
|
|
~allocator() {
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.allocator_unref();
|
2006-12-03 23:08:17 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
2006-12-03 23:08:17 +00:00
|
|
|
allocator& operator=(allocator const& x) {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(allocator::allocator()) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator assignment operator.");
|
2006-12-03 23:08:17 +00:00
|
|
|
tag_ = x.tag_;
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-31 22:19:26 +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-05-21 17:14:11 +00:00
|
|
|
pointer address(reference r) {
|
2008-01-13 16:19:26 +00:00
|
|
|
//UNORDERED_SCOPE(allocator::address(reference)) {
|
|
|
|
|
// UNORDERED_EPOINT("Mock allocator address function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
//}
|
|
|
|
|
return pointer(&r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const_pointer address(const_reference r) {
|
2008-01-13 16:19:26 +00:00
|
|
|
//UNORDERED_SCOPE(allocator::address(const_reference)) {
|
|
|
|
|
// UNORDERED_EPOINT("Mock allocator const address function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
//}
|
|
|
|
|
return const_pointer(&r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pointer allocate(size_type n) {
|
|
|
|
|
T* ptr = 0;
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(allocator::allocate(size_type)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator allocate function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
ptr = (T*) malloc(n * sizeof(T));
|
|
|
|
|
if(!ptr) throw std::bad_alloc();
|
|
|
|
|
}
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.track_allocate((void*) ptr, n, sizeof(T), tag_);
|
2006-05-21 17:14:11 +00:00
|
|
|
return pointer(ptr);
|
|
|
|
|
|
|
|
|
|
//return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
|
|
|
|
|
}
|
|
|
|
|
|
Merged revisions 42882-42941 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r42887 | danieljames | 2008-01-20 21:32:04 +0000 (Sun, 20 Jan 2008) | 10 lines
Merged revisions 42590-42664,42667-42697,42699-42723,42725-42855,42857-42881 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r42881 | danieljames | 2008-01-20 17:37:21 +0000 (Sun, 20 Jan 2008) | 1 line
Include <new> to get std::bad_alloc.
........
................
r42892 | danieljames | 2008-01-21 13:03:16 +0000 (Mon, 21 Jan 2008) | 1 line
On some compilers the Rogue Wave/Apache stdcxx library doesn't have the normal std::distance, but instead has a variant that takes the result as the third parameter so it doesn't have to work out the type from the iterator.
................
r42893 | danieljames | 2008-01-21 13:07:58 +0000 (Mon, 21 Jan 2008) | 1 line
Fix a typo in the last commit.
................
r42895 | danieljames | 2008-01-21 13:33:29 +0000 (Mon, 21 Jan 2008) | 1 line
Remove tabs from the last checkin.
................
r42896 | danieljames | 2008-01-21 15:51:40 +0000 (Mon, 21 Jan 2008) | 1 line
Use Boost config to tell when we have a std::distance function. Also, no need for a macro.
................
r42908 | danieljames | 2008-01-21 21:37:04 +0000 (Mon, 21 Jan 2008) | 1 line
Use boost::long_long_type and boost::ulong_long_type.
................
r42921 | danieljames | 2008-01-23 11:43:35 +0000 (Wed, 23 Jan 2008) | 1 line
Remove some tabs.
................
r42922 | danieljames | 2008-01-23 11:46:28 +0000 (Wed, 23 Jan 2008) | 2 lines
Add missing include. Refs #1596
................
r42923 | danieljames | 2008-01-23 11:52:47 +0000 (Wed, 23 Jan 2008) | 2 lines
Always use void const* for the second parameter of allocate. Refs #1596.
................
r42936 | danieljames | 2008-01-23 22:22:16 +0000 (Wed, 23 Jan 2008) | 1 line
Use Boost style library name in the documentation.
................
r42937 | danieljames | 2008-01-23 22:22:32 +0000 (Wed, 23 Jan 2008) | 1 line
More tabs.
................
r42941 | danieljames | 2008-01-23 23:35:01 +0000 (Wed, 23 Jan 2008) | 1 line
Fix all the allocators.
................
[SVN r42943]
2008-01-23 23:39:59 +00:00
|
|
|
pointer allocate(size_type n, void const* u)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
|
|
|
|
T* ptr = 0;
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(allocator::allocate(size_type, const_pointer)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator allocate function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
ptr = (T*) malloc(n * sizeof(T));
|
|
|
|
|
if(!ptr) throw std::bad_alloc();
|
|
|
|
|
}
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.track_allocate((void*) ptr, n, sizeof(T), tag_);
|
2006-05-21 17:14:11 +00:00
|
|
|
return pointer(ptr);
|
|
|
|
|
|
|
|
|
|
//return pointer(static_cast<T*>(::operator new(n * sizeof(T))));
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-03 23:08:17 +00:00
|
|
|
void deallocate(pointer p, size_type n)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
|
|
|
|
//::operator delete((void*) p);
|
|
|
|
|
if(p) {
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.track_deallocate((void*) p, n, sizeof(T), tag_);
|
2006-05-21 17:14:11 +00:00
|
|
|
using namespace std;
|
|
|
|
|
free(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void construct(pointer p, T const& t) {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(allocator::construct(pointer, T)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator construct function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
new(p) T(t);
|
|
|
|
|
}
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
Merge latest changes for unordered. Improved compatability and a few tweaks.
Merged revisions 53127,53253,53256,53311,53314,53316-53318 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r53127 | danieljames | 2009-05-20 07:43:38 +0100 (Wed, 20 May 2009) | 1 line
Better configuration for boost.unordered.
........
r53253 | danieljames | 2009-05-25 20:14:07 +0100 (Mon, 25 May 2009) | 3 lines
Add explicit destructors to the unordered containers. Refs #2908.
Isn't really needed but it doesn't hurt.
........
r53256 | danieljames | 2009-05-25 20:45:23 +0100 (Mon, 25 May 2009) | 1 line
Unordered change log for explicit destructors.
........
r53311 | danieljames | 2009-05-27 18:42:01 +0100 (Wed, 27 May 2009) | 1 line
Missing changelog entry.
........
r53314 | danieljames | 2009-05-27 18:44:09 +0100 (Wed, 27 May 2009) | 1 line
Use lightweight_test for unordered.
........
r53316 | danieljames | 2009-05-27 19:19:32 +0100 (Wed, 27 May 2009) | 1 line
Some workarounds for old versions of Borland.
........
r53317 | danieljames | 2009-05-27 19:32:22 +0100 (Wed, 27 May 2009) | 1 line
Fix a change accidentally included in the last commit.
........
r53318 | danieljames | 2009-05-27 19:32:38 +0100 (Wed, 27 May 2009) | 1 line
Remove an unused function.
........
[SVN r53465]
2009-05-30 17:34:12 +00:00
|
|
|
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
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
|
|
|
template<class... Args> void construct(pointer p, Args&&... args) {
|
|
|
|
|
UNORDERED_SCOPE(allocator::construct(pointer, Args&&...)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator construct function.");
|
|
|
|
|
new(p) T(std::forward<Args>(args)...);
|
|
|
|
|
}
|
|
|
|
|
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-12-03 23:08:17 +00:00
|
|
|
void destroy(pointer p) {
|
2008-01-10 22:30:46 +00:00
|
|
|
detail::tracker.track_destroy((void*) p, sizeof(T), tag_);
|
2006-12-03 23:08:17 +00:00
|
|
|
p->~T();
|
|
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
|
|
|
|
size_type max_size() const {
|
2008-01-13 16:19:26 +00:00
|
|
|
UNORDERED_SCOPE(allocator::construct(pointer, T)) {
|
|
|
|
|
UNORDERED_EPOINT("Mock allocator max_size function.");
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
return (std::numeric_limits<std::size_t>::max)();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2007-07-17 23:17:21 +00:00
|
|
|
template <class T>
|
|
|
|
|
void swap(allocator<T>& x, allocator<T>& y)
|
|
|
|
|
{
|
|
|
|
|
std::swap(x.tag_, y.tag_);
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-31 22:19:26 +00:00
|
|
|
// It's pretty much impossible to write a compliant swap when these
|
|
|
|
|
// two can throw. So they don't.
|
|
|
|
|
|
2006-05-21 17:14:11 +00:00
|
|
|
template <class T>
|
2006-12-03 23:08:17 +00:00
|
|
|
inline bool operator==(allocator<T> const& x, allocator<T> const& y)
|
2006-05-21 17:14:11 +00:00
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
//UNORDERED_SCOPE(operator==(allocator, allocator)) {
|
|
|
|
|
// UNORDERED_EPOINT("Mock allocator equality operator.");
|
2006-05-21 17:14:11 +00:00
|
|
|
//}
|
2006-12-03 23:08:17 +00:00
|
|
|
return x.tag_ == y.tag_;
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
|
inline bool operator!=(allocator<T> const& x, allocator<T> const& y)
|
|
|
|
|
{
|
2008-01-13 16:19:26 +00:00
|
|
|
//UNORDERED_SCOPE(operator!=(allocator, allocator)) {
|
|
|
|
|
// UNORDERED_EPOINT("Mock allocator inequality operator.");
|
2006-05-21 17:14:11 +00:00
|
|
|
//}
|
2006-12-03 23:08:17 +00:00
|
|
|
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)
|
|
|
|
|
namespace test
|
|
|
|
|
{
|
|
|
|
|
test::exception::object generate(test::exception::object const* x) {
|
|
|
|
|
return test::exception::generate(x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-05-21 17:14:11 +00:00
|
|
|
#endif
|
2006-12-03 23:08:17 +00:00
|
|
|
|