summaryrefslogtreecommitdiff
path: root/boost/container/detail/destroyers.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/container/detail/destroyers.hpp')
-rw-r--r--boost/container/detail/destroyers.hpp86
1 files changed, 42 insertions, 44 deletions
diff --git a/boost/container/detail/destroyers.hpp b/boost/container/detail/destroyers.hpp
index ea9b617..52b44c0 100644
--- a/boost/container/detail/destroyers.hpp
+++ b/boost/container/detail/destroyers.hpp
@@ -13,16 +13,20 @@
#ifndef BOOST_CONTAINER_DESTROYERS_HPP
#define BOOST_CONTAINER_DESTROYERS_HPP
-#if defined(_MSC_VER)
+#ifndef BOOST_CONFIG_HPP
+# include <boost/config.hpp>
+#endif
+
+#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
-#include <boost/container/detail/version_type.hpp>
-#include <boost/container/detail/utilities.hpp>
#include <boost/container/allocator_traits.hpp>
+#include <boost/container/detail/to_raw_pointer.hpp>
+#include <boost/container/detail/version_type.hpp>
namespace boost {
namespace container {
@@ -30,22 +34,20 @@ namespace container_detail {
//!A deleter for scoped_ptr that deallocates the memory
//!allocated for an object using a STL allocator.
-template <class A>
+template <class Allocator>
struct scoped_deallocator
{
- typedef allocator_traits<A> allocator_traits_type;
+ typedef allocator_traits<Allocator> allocator_traits_type;
typedef typename allocator_traits_type::pointer pointer;
typedef container_detail::integral_constant<unsigned,
boost::container::container_detail::
- version<A>::value> alloc_version;
- typedef container_detail::integral_constant<unsigned, 1> allocator_v1;
- typedef container_detail::integral_constant<unsigned, 2> allocator_v2;
+ version<Allocator>::value> alloc_version;
private:
- void priv_deallocate(allocator_v1)
+ void priv_deallocate(version_1)
{ m_alloc.deallocate(m_ptr, 1); }
- void priv_deallocate(allocator_v2)
+ void priv_deallocate(version_2)
{ m_alloc.deallocate_one(m_ptr); }
BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator)
@@ -53,9 +55,9 @@ struct scoped_deallocator
public:
pointer m_ptr;
- A& m_alloc;
+ Allocator& m_alloc;
- scoped_deallocator(pointer p, A& a)
+ scoped_deallocator(pointer p, Allocator& a)
: m_ptr(p), m_alloc(a)
{}
@@ -143,8 +145,6 @@ struct scoped_destroy_deallocator
typedef container_detail::integral_constant<unsigned,
boost::container::container_detail::
version<Allocator>::value> alloc_version;
- typedef container_detail::integral_constant<unsigned, 1> allocator_v1;
- typedef container_detail::integral_constant<unsigned, 2> allocator_v2;
scoped_destroy_deallocator(pointer p, Allocator& a)
: m_ptr(p), m_alloc(a) {}
@@ -162,10 +162,10 @@ struct scoped_destroy_deallocator
private:
- void priv_deallocate(const pointer &p, allocator_v1)
+ void priv_deallocate(const pointer &p, version_1)
{ AllocTraits::deallocate(m_alloc, p, 1); }
- void priv_deallocate(const pointer &p, allocator_v2)
+ void priv_deallocate(const pointer &p, version_2)
{ m_alloc.deallocate_one(p); }
pointer m_ptr;
@@ -239,13 +239,13 @@ struct null_scoped_destructor_n
{}
};
-template<class A>
+template<class Allocator>
class scoped_destructor
{
- typedef boost::container::allocator_traits<A> AllocTraits;
+ typedef boost::container::allocator_traits<Allocator> AllocTraits;
public:
- typedef typename A::value_type value_type;
- scoped_destructor(A &a, value_type *pv)
+ typedef typename Allocator::value_type value_type;
+ scoped_destructor(Allocator &a, value_type *pv)
: pv_(pv), a_(a)
{}
@@ -266,17 +266,17 @@ class scoped_destructor
private:
value_type *pv_;
- A &a_;
+ Allocator &a_;
};
-template<class A>
+template<class Allocator>
class value_destructor
{
- typedef boost::container::allocator_traits<A> AllocTraits;
+ typedef boost::container::allocator_traits<Allocator> AllocTraits;
public:
- typedef typename A::value_type value_type;
- value_destructor(A &a, value_type &rv)
+ typedef typename Allocator::value_type value_type;
+ value_destructor(Allocator &a, value_type &rv)
: rv_(rv), a_(a)
{}
@@ -287,7 +287,7 @@ class value_destructor
private:
value_type &rv_;
- A &a_;
+ Allocator &a_;
};
template <class Allocator>
@@ -299,21 +299,19 @@ class allocator_destroyer
typedef container_detail::integral_constant<unsigned,
boost::container::container_detail::
version<Allocator>::value> alloc_version;
- typedef container_detail::integral_constant<unsigned, 1> allocator_v1;
- typedef container_detail::integral_constant<unsigned, 2> allocator_v2;
private:
Allocator & a_;
private:
- void priv_deallocate(const pointer &p, allocator_v1)
+ void priv_deallocate(const pointer &p, version_1)
{ AllocTraits::deallocate(a_,p, 1); }
- void priv_deallocate(const pointer &p, allocator_v2)
+ void priv_deallocate(const pointer &p, version_2)
{ a_.deallocate_one(p); }
public:
- allocator_destroyer(Allocator &a)
+ explicit allocator_destroyer(Allocator &a)
: a_(a)
{}
@@ -324,41 +322,41 @@ class allocator_destroyer
}
};
-template <class A>
+template <class Allocator>
class allocator_destroyer_and_chain_builder
{
- typedef allocator_traits<A> allocator_traits_type;
+ typedef allocator_traits<Allocator> allocator_traits_type;
typedef typename allocator_traits_type::value_type value_type;
- typedef typename A::multiallocation_chain multiallocation_chain;
+ typedef typename Allocator::multiallocation_chain multiallocation_chain;
- A & a_;
+ Allocator & a_;
multiallocation_chain &c_;
public:
- allocator_destroyer_and_chain_builder(A &a, multiallocation_chain &c)
+ allocator_destroyer_and_chain_builder(Allocator &a, multiallocation_chain &c)
: a_(a), c_(c)
{}
- void operator()(const typename A::pointer &p)
+ void operator()(const typename Allocator::pointer &p)
{
- allocator_traits<A>::destroy(a_, container_detail::to_raw_pointer(p));
+ allocator_traits<Allocator>::destroy(a_, container_detail::to_raw_pointer(p));
c_.push_back(p);
}
};
-template <class A>
+template <class Allocator>
class allocator_multialloc_chain_node_deallocator
{
- typedef allocator_traits<A> allocator_traits_type;
+ typedef allocator_traits<Allocator> allocator_traits_type;
typedef typename allocator_traits_type::value_type value_type;
- typedef typename A::multiallocation_chain multiallocation_chain;
- typedef allocator_destroyer_and_chain_builder<A> chain_builder;
+ typedef typename Allocator::multiallocation_chain multiallocation_chain;
+ typedef allocator_destroyer_and_chain_builder<Allocator> chain_builder;
- A & a_;
+ Allocator & a_;
multiallocation_chain c_;
public:
- allocator_multialloc_chain_node_deallocator(A &a)
+ allocator_multialloc_chain_node_deallocator(Allocator &a)
: a_(a), c_()
{}