Change clang format indentation + .editorconfig file

This commit is contained in:
Daniel James
2017-06-11 20:55:59 +01:00
parent 5190a5d7f8
commit 0676b4f4ca
77 changed files with 14088 additions and 14027 deletions
+133 -133
View File
@@ -14,141 +14,141 @@
#include "../helpers/memory.hpp"
namespace test {
struct allocator_false
{
struct allocator_false
{
enum
{
is_select_on_copy = 0,
is_propagate_on_swap = 0,
is_propagate_on_assign = 0,
is_propagate_on_move = 0,
cxx11_construct = 0
is_select_on_copy = 0,
is_propagate_on_swap = 0,
is_propagate_on_assign = 0,
is_propagate_on_move = 0,
cxx11_construct = 0
};
};
};
struct allocator_flags_all
{
struct allocator_flags_all
{
enum
{
is_select_on_copy = 1,
is_propagate_on_swap = 1,
is_propagate_on_assign = 1,
is_propagate_on_move = 1,
cxx11_construct = 1
is_select_on_copy = 1,
is_propagate_on_swap = 1,
is_propagate_on_assign = 1,
is_propagate_on_move = 1,
cxx11_construct = 1
};
};
};
struct select_copy : allocator_false
{
struct select_copy : allocator_false
{
enum
{
is_select_on_copy = 1
is_select_on_copy = 1
};
};
struct propagate_swap : allocator_false
{
};
struct propagate_swap : allocator_false
{
enum
{
is_propagate_on_swap = 1
is_propagate_on_swap = 1
};
};
struct propagate_assign : allocator_false
{
};
struct propagate_assign : allocator_false
{
enum
{
is_propagate_on_assign = 1
is_propagate_on_assign = 1
};
};
struct propagate_move : allocator_false
{
};
struct propagate_move : allocator_false
{
enum
{
is_propagate_on_move = 1
is_propagate_on_move = 1
};
};
};
struct no_select_copy : allocator_flags_all
{
struct no_select_copy : allocator_flags_all
{
enum
{
is_select_on_copy = 0
is_select_on_copy = 0
};
};
struct no_propagate_swap : allocator_flags_all
{
};
struct no_propagate_swap : allocator_flags_all
{
enum
{
is_propagate_on_swap = 0
is_propagate_on_swap = 0
};
};
struct no_propagate_assign : allocator_flags_all
{
};
struct no_propagate_assign : allocator_flags_all
{
enum
{
is_propagate_on_assign = 0
is_propagate_on_assign = 0
};
};
struct no_propagate_move : allocator_flags_all
{
};
struct no_propagate_move : allocator_flags_all
{
enum
{
is_propagate_on_move = 0
is_propagate_on_move = 0
};
};
};
template <typename Flag> struct swap_allocator_base
{
template <typename Flag> struct swap_allocator_base
{
struct propagate_on_container_swap
{
enum
{
value = Flag::is_propagate_on_swap
};
enum
{
value = Flag::is_propagate_on_swap
};
};
};
};
template <typename Flag> struct assign_allocator_base
{
template <typename Flag> struct assign_allocator_base
{
struct propagate_on_container_copy_assignment
{
enum
{
value = Flag::is_propagate_on_assign
};
enum
{
value = Flag::is_propagate_on_assign
};
};
};
};
template <typename Flag> struct move_allocator_base
{
template <typename Flag> struct move_allocator_base
{
struct propagate_on_container_move_assignment
{
enum
{
value = Flag::is_propagate_on_move
};
enum
{
value = Flag::is_propagate_on_move
};
};
};
};
namespace {
// boostinspect:nounnamed
bool force_equal_allocator_value = false;
}
namespace {
// boostinspect:nounnamed
bool force_equal_allocator_value = false;
}
struct force_equal_allocator
{
struct force_equal_allocator
{
bool old_value_;
explicit force_equal_allocator(bool value)
: old_value_(force_equal_allocator_value)
{
force_equal_allocator_value = value;
force_equal_allocator_value = value;
}
~force_equal_allocator() { force_equal_allocator_value = old_value_; }
};
};
template <typename T> struct cxx11_allocator_base
{
template <typename T> struct cxx11_allocator_base
{
int tag_;
int selected_;
@@ -162,20 +162,20 @@ template <typename T> struct cxx11_allocator_base
explicit cxx11_allocator_base(int t) : tag_(t), selected_(0)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
template <typename Y>
cxx11_allocator_base(cxx11_allocator_base<Y> const& x)
: tag_(x.tag_), selected_(x.selected_)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
cxx11_allocator_base(cxx11_allocator_base const& x)
: tag_(x.tag_), selected_(x.selected_)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
~cxx11_allocator_base() { detail::tracker.allocator_unref(); }
@@ -186,71 +186,71 @@ template <typename T> struct cxx11_allocator_base
pointer allocate(size_type n)
{
pointer ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
pointer ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
}
pointer allocate(size_type n, void const*)
{
pointer ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
pointer ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
}
void deallocate(pointer p, size_type n)
{
// Only checking tags when propagating swap.
// Note that tags will be tested
// properly in the normal allocator.
detail::tracker.track_deallocate(
(void*)p, n, sizeof(T), tag_, !force_equal_allocator_value);
::operator delete((void*)p);
// Only checking tags when propagating swap.
// Note that tags will be tested
// properly in the normal allocator.
detail::tracker.track_deallocate(
(void*)p, n, sizeof(T), tag_, !force_equal_allocator_value);
::operator delete((void*)p);
}
void construct(T* p, T const& t)
{
detail::tracker.track_construct((void*)p, sizeof(T), tag_);
new (p) T(t);
detail::tracker.track_construct((void*)p, sizeof(T), tag_);
new (p) T(t);
}
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <typename... Args>
void construct(T* p, BOOST_FWD_REF(Args)... args)
{
detail::tracker.track_construct((void*)p, sizeof(T), tag_);
new (p) T(boost::forward<Args>(args)...);
detail::tracker.track_construct((void*)p, sizeof(T), tag_);
new (p) T(boost::forward<Args>(args)...);
}
#endif
void destroy(T* p)
{
detail::tracker.track_destroy((void*)p, sizeof(T), tag_);
p->~T();
detail::tracker.track_destroy((void*)p, sizeof(T), tag_);
p->~T();
}
size_type max_size() const
{
return (std::numeric_limits<size_type>::max)();
return (std::numeric_limits<size_type>::max)();
}
};
};
template <typename T, typename Flags = propagate_swap, typename Enable = void>
struct cxx11_allocator;
template <typename T, typename Flags = propagate_swap, typename Enable = void>
struct cxx11_allocator;
template <typename T, typename Flags>
struct cxx11_allocator<T, Flags,
template <typename T, typename Flags>
struct cxx11_allocator<T, Flags,
typename boost::disable_if_c<Flags::is_select_on_copy>::type>
: public cxx11_allocator_base<T>,
public swap_allocator_base<Flags>,
public assign_allocator_base<Flags>,
public move_allocator_base<Flags>,
Flags
{
{
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 402000)
template <typename U> struct rebind
{
typedef cxx11_allocator<U, Flags> other;
typedef cxx11_allocator<U, Flags> other;
};
#endif
@@ -268,32 +268,32 @@ struct cxx11_allocator<T, Flags,
// to avoid undefined behaviour.
bool operator==(cxx11_allocator const& x) const
{
return force_equal_allocator_value || (this->tag_ == x.tag_);
return force_equal_allocator_value || (this->tag_ == x.tag_);
}
bool operator!=(cxx11_allocator const& x) const { return !(*this == x); }
};
};
template <typename T, typename Flags>
struct cxx11_allocator<T, Flags,
template <typename T, typename Flags>
struct cxx11_allocator<T, Flags,
typename boost::enable_if_c<Flags::is_select_on_copy>::type>
: public cxx11_allocator_base<T>,
public swap_allocator_base<Flags>,
public assign_allocator_base<Flags>,
public move_allocator_base<Flags>,
Flags
{
{
cxx11_allocator select_on_container_copy_construction() const
{
cxx11_allocator tmp(*this);
++tmp.selected_;
return tmp;
cxx11_allocator tmp(*this);
++tmp.selected_;
return tmp;
}
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 402000)
template <typename U> struct rebind
{
typedef cxx11_allocator<U, Flags> other;
typedef cxx11_allocator<U, Flags> other;
};
#endif
@@ -311,34 +311,34 @@ struct cxx11_allocator<T, Flags,
// to avoid undefined behaviour.
bool operator==(cxx11_allocator const& x) const
{
return force_equal_allocator_value || (this->tag_ == x.tag_);
return force_equal_allocator_value || (this->tag_ == x.tag_);
}
bool operator!=(cxx11_allocator const& x) const { return !(*this == x); }
};
};
template <typename T, typename Flags>
bool equivalent_impl(cxx11_allocator<T, Flags> const& x,
template <typename T, typename Flags>
bool equivalent_impl(cxx11_allocator<T, Flags> const& x,
cxx11_allocator<T, Flags> const& y, test::derived_type)
{
{
return x.tag_ == y.tag_;
}
}
// Function to check how many times an allocator has been selected,
// return 0 for other allocators.
// Function to check how many times an allocator has been selected,
// return 0 for other allocators.
struct convert_from_anything
{
struct convert_from_anything
{
template <typename T> convert_from_anything(T const&) {}
};
};
inline int selected_count(convert_from_anything) { return 0; }
inline int selected_count(convert_from_anything) { return 0; }
template <typename T, typename Flags>
int selected_count(cxx11_allocator<T, Flags> const& x)
{
template <typename T, typename Flags>
int selected_count(cxx11_allocator<T, Flags> const& x)
{
return x.selected_;
}
}
}
#endif
+407 -408
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -7,11 +7,11 @@
#define BOOST_UNORDERED_TEST_OBJECTS_FWD_HEADER
namespace test {
class object;
class hash;
class less;
class equal_to;
template <class T> class allocator;
class object;
class hash;
class less;
class equal_to;
template <class T> class allocator;
}
#endif
+435 -423
View File
File diff suppressed because it is too large Load Diff
+234 -234
View File
@@ -14,25 +14,25 @@
#include <cstddef>
namespace test {
// Note that the default hash function will work for any equal_to (but not
// very well).
class object;
class movable;
class implicitly_convertible;
class hash;
class less;
class equal_to;
template <class T> class allocator1;
template <class T> class allocator2;
object generate(object const*, random_generator);
movable generate(movable const*, random_generator);
implicitly_convertible generate(
// Note that the default hash function will work for any equal_to (but not
// very well).
class object;
class movable;
class implicitly_convertible;
class hash;
class less;
class equal_to;
template <class T> class allocator1;
template <class T> class allocator2;
object generate(object const*, random_generator);
movable generate(movable const*, random_generator);
implicitly_convertible generate(
implicitly_convertible const*, random_generator);
inline void ignore_variable(void const*) {}
inline void ignore_variable(void const*) {}
class object : private counted_object
{
class object : private counted_object
{
friend class hash;
friend class equal_to;
friend class less;
@@ -43,40 +43,40 @@ class object : private counted_object
~object()
{
tag1_ = -1;
tag2_ = -1;
tag1_ = -1;
tag2_ = -1;
}
friend bool operator==(object const& x1, object const& x2)
{
return x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_;
return x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_;
}
friend bool operator!=(object const& x1, object const& x2)
{
return x1.tag1_ != x2.tag1_ || x1.tag2_ != x2.tag2_;
return x1.tag1_ != x2.tag1_ || x1.tag2_ != x2.tag2_;
}
friend bool operator<(object const& x1, object const& x2)
{
return x1.tag1_ < x2.tag1_ ||
(x1.tag1_ == x2.tag1_ && x1.tag2_ < x2.tag2_);
return x1.tag1_ < x2.tag1_ ||
(x1.tag1_ == x2.tag1_ && x1.tag2_ < x2.tag2_);
}
friend object generate(object const*, random_generator g)
{
int* x = 0;
return object(generate(x, g), generate(x, g));
int* x = 0;
return object(generate(x, g), generate(x, g));
}
friend std::ostream& operator<<(std::ostream& out, object const& o)
{
return out << "(" << o.tag1_ << "," << o.tag2_ << ")";
return out << "(" << o.tag1_ << "," << o.tag2_ << ")";
}
};
};
class movable : private counted_object
{
class movable : private counted_object
{
friend class hash;
friend class equal_to;
friend class less;
@@ -89,74 +89,74 @@ class movable : private counted_object
movable(movable const& x)
: counted_object(x), tag1_(x.tag1_), tag2_(x.tag2_)
{
BOOST_TEST(x.tag1_ != -1);
BOOST_TEST(x.tag1_ != -1);
}
movable(BOOST_RV_REF(movable) x)
: counted_object(x), tag1_(x.tag1_), tag2_(x.tag2_)
{
BOOST_TEST(x.tag1_ != -1);
x.tag1_ = -1;
x.tag2_ = -1;
BOOST_TEST(x.tag1_ != -1);
x.tag1_ = -1;
x.tag2_ = -1;
}
movable& operator=(BOOST_COPY_ASSIGN_REF(movable) x) // Copy assignment
{
BOOST_TEST(x.tag1_ != -1);
tag1_ = x.tag1_;
tag2_ = x.tag2_;
return *this;
BOOST_TEST(x.tag1_ != -1);
tag1_ = x.tag1_;
tag2_ = x.tag2_;
return *this;
}
movable& operator=(BOOST_RV_REF(movable) x) // Move assignment
{
BOOST_TEST(x.tag1_ != -1);
tag1_ = x.tag1_;
tag2_ = x.tag2_;
x.tag1_ = -1;
x.tag2_ = -1;
return *this;
BOOST_TEST(x.tag1_ != -1);
tag1_ = x.tag1_;
tag2_ = x.tag2_;
x.tag1_ = -1;
x.tag2_ = -1;
return *this;
}
~movable()
{
tag1_ = -1;
tag2_ = -1;
tag1_ = -1;
tag2_ = -1;
}
friend bool operator==(movable const& x1, movable const& x2)
{
BOOST_TEST(x1.tag1_ != -1 && x2.tag1_ != -1);
return x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_;
BOOST_TEST(x1.tag1_ != -1 && x2.tag1_ != -1);
return x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_;
}
friend bool operator!=(movable const& x1, movable const& x2)
{
BOOST_TEST(x1.tag1_ != -1 && x2.tag1_ != -1);
return x1.tag1_ != x2.tag1_ || x1.tag2_ != x2.tag2_;
BOOST_TEST(x1.tag1_ != -1 && x2.tag1_ != -1);
return x1.tag1_ != x2.tag1_ || x1.tag2_ != x2.tag2_;
}
friend bool operator<(movable const& x1, movable const& x2)
{
BOOST_TEST(x1.tag1_ != -1 && x2.tag1_ != -1);
return x1.tag1_ < x2.tag1_ ||
(x1.tag1_ == x2.tag1_ && x1.tag2_ < x2.tag2_);
BOOST_TEST(x1.tag1_ != -1 && x2.tag1_ != -1);
return x1.tag1_ < x2.tag1_ ||
(x1.tag1_ == x2.tag1_ && x1.tag2_ < x2.tag2_);
}
friend movable generate(movable const*, random_generator g)
{
int* x = 0;
return movable(generate(x, g), generate(x, g));
int* x = 0;
return movable(generate(x, g), generate(x, g));
}
friend std::ostream& operator<<(std::ostream& out, movable const& o)
{
return out << "(" << o.tag1_ << "," << o.tag2_ << ")";
return out << "(" << o.tag1_ << "," << o.tag2_ << ")";
}
};
};
class implicitly_convertible : private counted_object
{
class implicitly_convertible : private counted_object
{
int tag1_, tag2_;
public:
@@ -170,22 +170,22 @@ class implicitly_convertible : private counted_object
operator movable() const { return movable(tag1_, tag2_); }
friend implicitly_convertible generate(
implicitly_convertible const*, random_generator g)
implicitly_convertible const*, random_generator g)
{
int* x = 0;
return implicitly_convertible(generate(x, g), generate(x, g));
int* x = 0;
return implicitly_convertible(generate(x, g), generate(x, g));
}
friend std::ostream& operator<<(
std::ostream& out, implicitly_convertible const& o)
std::ostream& out, implicitly_convertible const& o)
{
return out << "(" << o.tag1_ << "," << o.tag2_ << ")";
return out << "(" << o.tag1_ << "," << o.tag2_ << ")";
}
};
};
// Note: This is a deliberately bad hash function.
class hash
{
// Note: This is a deliberately bad hash function.
class hash
{
int type_;
public:
@@ -193,69 +193,69 @@ class hash
std::size_t operator()(object const& x) const
{
int result;
switch (type_) {
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);
int result;
switch (type_) {
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);
}
std::size_t operator()(movable const& x) const
{
int result;
switch (type_) {
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);
int result;
switch (type_) {
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);
}
std::size_t operator()(int x) const
{
int result;
switch (type_) {
case 1:
result = x;
break;
case 2:
result = x * 7;
break;
default:
result = x * 256;
}
return static_cast<std::size_t>(result);
int result;
switch (type_) {
case 1:
result = x;
break;
case 2:
result = x * 7;
break;
default:
result = x * 256;
}
return static_cast<std::size_t>(result);
}
friend bool operator==(hash const& x1, hash const& x2)
{
return x1.type_ == x2.type_;
return x1.type_ == x2.type_;
}
friend bool operator!=(hash const& x1, hash const& x2)
{
return x1.type_ != x2.type_;
return x1.type_ != x2.type_;
}
};
};
std::size_t hash_value(test::object const& x) { return hash()(x); }
std::size_t hash_value(test::object const& x) { return hash()(x); }
std::size_t hash_value(test::movable const& x) { return hash()(x); }
std::size_t hash_value(test::movable const& x) { return hash()(x); }
class less
{
class less
{
int type_;
public:
@@ -263,38 +263,38 @@ class less
bool operator()(object const& x1, object const& x2) const
{
switch (type_) {
case 1:
return x1.tag1_ < x2.tag1_;
case 2:
return x1.tag2_ < x2.tag2_;
default:
return x1 < x2;
}
switch (type_) {
case 1:
return x1.tag1_ < x2.tag1_;
case 2:
return x1.tag2_ < x2.tag2_;
default:
return x1 < x2;
}
}
bool operator()(movable const& x1, movable const& x2) const
{
switch (type_) {
case 1:
return x1.tag1_ < x2.tag1_;
case 2:
return x1.tag2_ < x2.tag2_;
default:
return x1 < x2;
}
switch (type_) {
case 1:
return x1.tag1_ < x2.tag1_;
case 2:
return x1.tag2_ < x2.tag2_;
default:
return x1 < x2;
}
}
std::size_t operator()(int x1, int x2) const { return x1 < x2; }
friend bool operator==(less const& x1, less const& x2)
{
return x1.type_ == x2.type_;
return x1.type_ == x2.type_;
}
};
};
class equal_to
{
class equal_to
{
int type_;
public:
@@ -302,48 +302,48 @@ class equal_to
bool operator()(object const& x1, object const& x2) const
{
switch (type_) {
case 1:
return x1.tag1_ == x2.tag1_;
case 2:
return x1.tag2_ == x2.tag2_;
default:
return x1 == x2;
}
switch (type_) {
case 1:
return x1.tag1_ == x2.tag1_;
case 2:
return x1.tag2_ == x2.tag2_;
default:
return x1 == x2;
}
}
bool operator()(movable const& x1, movable const& x2) const
{
switch (type_) {
case 1:
return x1.tag1_ == x2.tag1_;
case 2:
return x1.tag2_ == x2.tag2_;
default:
return x1 == x2;
}
switch (type_) {
case 1:
return x1.tag1_ == x2.tag1_;
case 2:
return x1.tag2_ == x2.tag2_;
default:
return x1 == x2;
}
}
std::size_t operator()(int x1, int x2) const { return x1 == x2; }
friend bool operator==(equal_to const& x1, equal_to const& x2)
{
return x1.type_ == x2.type_;
return x1.type_ == x2.type_;
}
friend bool operator!=(equal_to const& x1, equal_to const& x2)
{
return x1.type_ != x2.type_;
return x1.type_ != x2.type_;
}
friend less create_compare(equal_to x) { return less(x.type_); }
};
};
// allocator1 only has the old fashioned 'construct' method and has
// a few less typedefs. allocator2 uses a custom pointer class.
// allocator1 only has the old fashioned 'construct' method and has
// a few less typedefs. allocator2 uses a custom pointer class.
template <class T> class allocator1
{
template <class T> class allocator1
{
public:
int tag_;
@@ -351,60 +351,60 @@ template <class T> class allocator1
template <class U> struct rebind
{
typedef allocator1<U> other;
typedef allocator1<U> other;
};
explicit allocator1(int t = 0) : tag_(t)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
template <class Y> allocator1(allocator1<Y> const& x) : tag_(x.tag_)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
allocator1(allocator1 const& x) : tag_(x.tag_)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
~allocator1() { detail::tracker.allocator_unref(); }
T* allocate(std::size_t n)
{
T* ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
T* ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
}
T* allocate(std::size_t n, void const*)
{
T* ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
T* ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
}
void deallocate(T* p, std::size_t n)
{
detail::tracker.track_deallocate((void*)p, n, sizeof(T), tag_);
::operator delete((void*)p);
detail::tracker.track_deallocate((void*)p, n, sizeof(T), tag_);
::operator delete((void*)p);
}
#if BOOST_UNORDERED_CXX11_CONSTRUCTION
template <typename U, typename... Args> void construct(U* p, Args&&... args)
{
detail::tracker.track_construct((void*)p, sizeof(U), tag_);
new (p) U(boost::forward<Args>(args)...);
detail::tracker.track_construct((void*)p, sizeof(U), tag_);
new (p) U(boost::forward<Args>(args)...);
}
template <typename U> void destroy(U* p)
{
detail::tracker.track_destroy((void*)p, sizeof(U), tag_);
p->~U();
detail::tracker.track_destroy((void*)p, sizeof(U), tag_);
p->~U();
// Work around MSVC buggy unused parameter warning.
ignore_variable(&p);
// Work around MSVC buggy unused parameter warning.
ignore_variable(&p);
}
#else
private:
@@ -429,18 +429,18 @@ template <class T> class allocator1
enum
{
is_select_on_copy = false,
is_propagate_on_swap = false,
is_propagate_on_assign = false,
is_propagate_on_move = false
is_select_on_copy = false,
is_propagate_on_swap = false,
is_propagate_on_assign = false,
is_propagate_on_move = false
};
};
};
template <class T> class ptr;
template <class T> class const_ptr;
template <class T> class ptr;
template <class T> class const_ptr;
struct void_ptr
{
struct void_ptr
{
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
template <typename T> friend class ptr;
@@ -460,10 +460,10 @@ struct void_ptr
bool operator==(void_ptr const& x) const { return ptr_ == x.ptr_; }
bool operator!=(void_ptr const& x) const { return ptr_ != x.ptr_; }
};
};
class void_const_ptr
{
class void_const_ptr
{
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
template <typename T> friend class const_ptr;
@@ -486,10 +486,10 @@ class void_const_ptr
bool operator==(void_const_ptr const& x) const { return ptr_ == x.ptr_; }
bool operator!=(void_const_ptr const& x) const { return ptr_ != x.ptr_; }
};
};
template <class T> class ptr
{
template <class T> class ptr
{
friend class allocator2<T>;
friend class const_ptr<T>;
friend struct void_ptr;
@@ -505,14 +505,14 @@ template <class T> class ptr
T* operator->() const { return ptr_; }
ptr& operator++()
{
++ptr_;
return *this;
++ptr_;
return *this;
}
ptr operator++(int)
{
ptr tmp(*this);
++ptr_;
return tmp;
ptr tmp(*this);
++ptr_;
return tmp;
}
ptr operator+(std::ptrdiff_t s) const { return ptr<T>(ptr_ + s); }
friend ptr operator+(std::ptrdiff_t s, ptr p) { return ptr<T>(s + p.ptr_); }
@@ -529,10 +529,10 @@ template <class T> class ptr
bool operator>(ptr const& x) const { return ptr_ > x.ptr_; }
bool operator<=(ptr const& x) const { return ptr_ <= x.ptr_; }
bool operator>=(ptr const& x) const { return ptr_ >= x.ptr_; }
};
};
template <class T> class const_ptr
{
template <class T> class const_ptr
{
friend class allocator2<T>;
friend struct const_void_ptr;
@@ -548,19 +548,19 @@ template <class T> class const_ptr
T const* operator->() const { return ptr_; }
const_ptr& operator++()
{
++ptr_;
return *this;
++ptr_;
return *this;
}
const_ptr operator++(int)
{
const_ptr tmp(*this);
++ptr_;
return tmp;
const_ptr tmp(*this);
++ptr_;
return tmp;
}
const_ptr operator+(std::ptrdiff_t s) const { return const_ptr(ptr_ + s); }
friend const_ptr operator+(std::ptrdiff_t s, const_ptr p)
{
return ptr<T>(s + p.ptr_);
return ptr<T>(s + p.ptr_);
}
T const& operator[](int s) const { return ptr_[s]; }
bool operator!() const { return !ptr_; }
@@ -572,10 +572,10 @@ template <class T> class const_ptr
bool operator>(const_ptr const& x) const { return ptr_ > x.ptr_; }
bool operator<=(const_ptr const& x) const { return ptr_ <= x.ptr_; }
bool operator>=(const_ptr const& x) const { return ptr_ >= x.ptr_; }
};
};
template <class T> class allocator2
{
template <class T> class allocator2
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
@@ -596,22 +596,22 @@ template <class T> class allocator2
template <class U> struct rebind
{
typedef allocator2<U> other;
typedef allocator2<U> other;
};
explicit allocator2(int t = 0) : tag_(t)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
template <class Y> allocator2(allocator2<Y> const& x) : tag_(x.tag_)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
allocator2(allocator2 const& x) : tag_(x.tag_)
{
detail::tracker.allocator_ref();
detail::tracker.allocator_ref();
}
~allocator2() { detail::tracker.allocator_unref(); }
@@ -622,47 +622,47 @@ template <class T> class allocator2
pointer allocate(size_type n)
{
pointer p(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)p.ptr_, n, sizeof(T), tag_);
return p;
pointer p(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)p.ptr_, n, sizeof(T), tag_);
return p;
}
pointer allocate(size_type n, void const*)
{
pointer ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
pointer ptr(static_cast<T*>(::operator new(n * sizeof(T))));
detail::tracker.track_allocate((void*)ptr, n, sizeof(T), tag_);
return ptr;
}
void deallocate(pointer p, size_type n)
{
detail::tracker.track_deallocate((void*)p.ptr_, n, sizeof(T), tag_);
::operator delete((void*)p.ptr_);
detail::tracker.track_deallocate((void*)p.ptr_, n, sizeof(T), tag_);
::operator delete((void*)p.ptr_);
}
void construct(T* p, T const& t)
{
detail::tracker.track_construct((void*)p, sizeof(T), tag_);
new (p) T(t);
detail::tracker.track_construct((void*)p, sizeof(T), tag_);
new (p) T(t);
}
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args)
{
detail::tracker.track_construct((void*)p, sizeof(T), tag_);
new (p) T(boost::forward<Args>(args)...);
detail::tracker.track_construct((void*)p, sizeof(T), tag_);
new (p) T(boost::forward<Args>(args)...);
}
#endif
void destroy(T* p)
{
detail::tracker.track_destroy((void*)p, sizeof(T), tag_);
p->~T();
detail::tracker.track_destroy((void*)p, sizeof(T), tag_);
p->~T();
}
size_type max_size() const
{
return (std::numeric_limits<size_type>::max)();
return (std::numeric_limits<size_type>::max)();
}
bool operator==(allocator2 const& x) const { return tag_ == x.tag_; }
@@ -671,26 +671,26 @@ template <class T> class allocator2
enum
{
is_select_on_copy = false,
is_propagate_on_swap = false,
is_propagate_on_assign = false,
is_propagate_on_move = false
is_select_on_copy = false,
is_propagate_on_swap = false,
is_propagate_on_assign = false,
is_propagate_on_move = false
};
};
};
template <class T>
bool equivalent_impl(
template <class T>
bool equivalent_impl(
allocator1<T> const& x, allocator1<T> const& y, test::derived_type)
{
{
return x == y;
}
}
template <class T>
bool equivalent_impl(
template <class T>
bool equivalent_impl(
allocator2<T> const& x, allocator2<T> const& y, test::derived_type)
{
{
return x == y;
}
}
}
#endif