|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70660 - in trunk/boost/interprocess: . containers containers/container containers/container/detail detail smart_ptr sync/emulation
From: igaztanaga_at_[hidden]
Date: 2011-03-28 04:53:17
Author: igaztanaga
Date: 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
New Revision: 70660
URL: http://svn.boost.org/trac/boost/changeset/70660
Log:
Fixes to use pointers as key_types plus updated pair to recent C++0x draft. Fixed some missing config_begin.hpp/config_end.hpp includes. Fixed comparison operators for stable_vector iterator.
Text files modified:
trunk/boost/interprocess/containers/container/detail/math_functions.hpp | 3
trunk/boost/interprocess/containers/container/detail/mpl.hpp | 3
trunk/boost/interprocess/containers/container/detail/pair.hpp | 180 ++++++++++++++++++++++++++++++----------
trunk/boost/interprocess/containers/container/detail/tree.hpp | 54 +++++++++--
trunk/boost/interprocess/containers/container/detail/type_traits.hpp | 41 ++++++++
trunk/boost/interprocess/containers/container/detail/version_type.hpp | 3
trunk/boost/interprocess/containers/container/stable_vector.hpp | 165 ++++++++++++++++++++----------------
trunk/boost/interprocess/containers/pair.hpp | 1
trunk/boost/interprocess/detail/intersegment_ptr.hpp | 3
trunk/boost/interprocess/detail/managed_open_or_create_impl.hpp | 3
trunk/boost/interprocess/offset_ptr.hpp | 4
trunk/boost/interprocess/smart_ptr/enable_shared_from_this.hpp | 2
trunk/boost/interprocess/sync/emulation/mutex.hpp | 2
13 files changed, 326 insertions(+), 138 deletions(-)
Modified: trunk/boost/interprocess/containers/container/detail/math_functions.hpp
==============================================================================
--- trunk/boost/interprocess/containers/container/detail/math_functions.hpp (original)
+++ trunk/boost/interprocess/containers/container/detail/math_functions.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -16,6 +16,7 @@
#ifndef BOOST_CONTAINER_DETAIL_MATH_FUNCTIONS_HPP
#define BOOST_CONTAINER_DETAIL_MATH_FUNCTIONS_HPP
+#include "config_begin.hpp"
#include <climits>
#include <boost/static_assert.hpp>
@@ -107,4 +108,6 @@
} // namespace container
} // namespace boost
+#include INCLUDE_BOOST_CONTAINER_DETAIL_CONFIG_END_HPP
+
#endif
Modified: trunk/boost/interprocess/containers/container/detail/mpl.hpp
==============================================================================
--- trunk/boost/interprocess/containers/container/detail/mpl.hpp (original)
+++ trunk/boost/interprocess/containers/container/detail/mpl.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -62,6 +62,9 @@
template <class Cond, class T = void>
struct disable_if : public enable_if_c<!Cond::value, T> {};
+template <bool B, class T = void>
+struct disable_if_c : public enable_if_c<!B, T> {};
+
template <class T, class U>
class is_convertible
{
Modified: trunk/boost/interprocess/containers/container/detail/pair.hpp
==============================================================================
--- trunk/boost/interprocess/containers/container/detail/pair.hpp (original)
+++ trunk/boost/interprocess/containers/container/detail/pair.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -37,6 +37,32 @@
namespace containers_detail {
template <class T1, class T2>
+struct pair;
+
+template <class T>
+struct is_pair
+{
+ static const bool value = false;
+};
+
+template <class T1, class T2>
+struct is_pair< pair<T1, T2> >
+{
+ static const bool value = true;
+};
+
+template <class T1, class T2>
+struct is_pair< std::pair<T1, T2> >
+{
+ static const bool value = true;
+};
+
+struct pair_nat;
+
+struct piecewise_construct_t { };
+static const piecewise_construct_t piecewise_construct = piecewise_construct_t();
+
+template <class T1, class T2>
struct pair
{
private:
@@ -49,78 +75,103 @@
T1 first;
T2 second;
- //std::pair compatibility
- template <class D, class S>
- pair(const std::pair<D, S>& p)
- : first(p.first), second(p.second)
+ //Default constructor
+ pair()
+ : first(), second()
+ {}
+/*
+ //pair from two values
+ pair(const T1 &t1, const T2 &t2)
+ : first(t1)
+ , second(t2)
+ {}
+
+
+ //pair from two values
+ pair(BOOST_RV_REF(T1) t1, BOOST_RV_REF(T2) t2)
+ : first(::boost::move(t1))
+ , second(::boost::move(t2))
+ {}
+*/
+ template<class U, class V>
+ pair(BOOST_FWD_REF(U) u, BOOST_FWD_REF(V) v)
+ : first(::boost::forward<U>(u))
+ , second(::boost::forward<V>(v))
{}
- //To resolve ambiguity with the variadic constructor of 1 argument
- //and the previous constructor
- pair(std::pair<T1, T2>& x)
+ //pair copy assignment
+ pair(const pair& x)
: first(x.first), second(x.second)
{}
template <class D, class S>
- pair(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, D, S) p)
- : first(boost::move(p.first)), second(boost::move(p.second))
+ pair(const pair<D, S> &p)
+ : first(p.first), second(p.second)
{}
- pair()
- : first(), second()
+ //pair move constructor
+ pair(BOOST_RV_REF(pair) p)
+ : first(::boost::move(p.first)), second(::boost::move(p.second))
{}
- pair(const pair<T1, T2>& x)
- : first(x.first), second(x.second)
+ template <class D, class S>
+ pair(BOOST_RV_REF_2_TEMPL_ARGS(pair, D, S) p)
+ : first(::boost::move(p.first)), second(::boost::move(p.second))
{}
-/*
- //To resolve ambiguity with the variadic constructor of 1 argument
- //and the copy constructor
- pair(pair<T1, T2>& x)
+
+ //std::pair copy constructor
+ pair(const std::pair<T1, T2>& x)
: first(x.first), second(x.second)
{}
-*/
- pair(BOOST_RV_REF(pair) p)
- : first(boost::move(p.first)), second(boost::move(p.second))
+
+ template <class D, class S>
+ pair(const std::pair<D, S>& p)
+ : first(p.first), second(p.second)
{}
+ //std::pair move constructor
template <class D, class S>
- pair(BOOST_RV_REF_2_TEMPL_ARGS(pair, D, S) p)
- : first(boost::move(p.first)), second(boost::move(p.second))
+ pair(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, D, S) p)
+ : first(::boost::move(p.first)), second(::boost::move(p.second))
{}
- #ifdef BOOST_CONTAINERS_PERFECT_FORWARDING
+ pair(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, T1, T2) p)
+ : first(::boost::move(p.first)), second(::boost::move(p.second))
+ {}
- template<class U, class ...Args>
- pair(U &&u, Args &&... args)
- : first(boost::forward<U>(u))
- , second(boost::forward<Args>(args)...)
+ //piecewise_construct missing
+/*
+ //Variadic versions
+ template<class U>
+ pair(BOOST_CONTAINERS_PARAM(U, u), typename containers_detail::disable_if
+ < containers_detail::is_pair< typename containers_detail::remove_ref_const<U>::type >, pair_nat>::type* = 0)
+ : first(::boost::forward<U>(u))
+ , second()
{}
- #else
+ #ifdef BOOST_CONTAINERS_PERFECT_FORWARDING
- template<class U>
- pair( BOOST_CONTAINERS_PARAM(U, u)
- #ifdef BOOST_NO_RVALUE_REFERENCES
- , typename containers_detail::disable_if
- < containers_detail::is_same<U, ::boost::rv<pair> > >::type* = 0
- #endif
- )
- : first(boost::forward<U>(const_cast<U&>(u)))
+ template<class U, class V, class ...Args>
+ pair(U &&u, V &&v)
+ : first(::boost::forward<U>(u))
+ , second(::boost::forward<V>(v), ::boost::forward<Args>(args)...)
{}
+ #else
+
#define BOOST_PP_LOCAL_MACRO(n) \
template<class U, BOOST_PP_ENUM_PARAMS(n, class P)> \
pair(BOOST_CONTAINERS_PARAM(U, u) \
,BOOST_PP_ENUM(n, BOOST_CONTAINERS_PP_PARAM_LIST, _)) \
- : first(boost::forward<U>(const_cast<U&>(u))) \
+ : first(::boost::forward<U>(u)) \
, second(BOOST_PP_ENUM(n, BOOST_CONTAINERS_PP_PARAM_FORWARD, _)) \
{} \
//!
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINERS_MAX_CONSTRUCTOR_PARAMETERS)
#include BOOST_PP_LOCAL_ITERATE()
#endif
-
+*/
+ //pair copy assignment
pair& operator=(BOOST_COPY_ASSIGN_REF(pair) p)
{
first = p.first;
@@ -128,30 +179,69 @@
return *this;
}
+ template <class D, class S>
+ pair& operator=(const pair<D, S>&p)
+ {
+ first = p.first;
+ second = p.second;
+ return *this;
+ }
+
+ //pair move assignment
pair& operator=(BOOST_RV_REF(pair) p)
{
- first = boost::move(p.first);
- second = boost::move(p.second);
+ first = ::boost::move(p.first);
+ second = ::boost::move(p.second);
+ return *this;
+ }
+
+ template <class D, class S>
+ pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(pair, D, S) p)
+ {
+ first = ::boost::move(p.first);
+ second = ::boost::move(p.second);
+ return *this;
+ }
+
+ //std::pair copy assignment
+ pair& operator=(const std::pair<T1, T2> &p)
+ {
+ first = p.first;
+ second = p.second;
+ return *this;
+ }
+
+ template <class D, class S>
+ pair& operator=(const std::pair<D, S> &p)
+ {
+ first = ::boost::move(p.first);
+ second = ::boost::move(p.second);
return *this;
}
+ //std::pair move assignment
pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, T1, T2) p)
{
- first = boost::move(p.first);
- second = boost::move(p.second);
+ first = ::boost::move(p.first);
+ second = ::boost::move(p.second);
return *this;
}
template <class D, class S>
pair& operator=(BOOST_RV_REF_2_TEMPL_ARGS(std::pair, D, S) p)
{
- first = boost::move(p.first);
- second = boost::move(p.second);
+ first = ::boost::move(p.first);
+ second = ::boost::move(p.second);
return *this;
}
+ //swap
void swap(pair& p)
- { std::swap(*this, p); }
+ {
+ using std::swap;
+ swap(this->first, p.first);
+ swap(this->second, p.second);
+ }
};
template <class T1, class T2>
Modified: trunk/boost/interprocess/containers/container/detail/tree.hpp
==============================================================================
--- trunk/boost/interprocess/containers/container/detail/tree.hpp (original)
+++ trunk/boost/interprocess/containers/container/detail/tree.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -47,7 +47,7 @@
typedef KeyOfValue key_of_value;
typedef Key key_type;
- value_compare_impl(key_compare kcomp)
+ value_compare_impl(const key_compare &kcomp)
: key_compare(kcomp)
{}
@@ -57,9 +57,25 @@
key_compare &key_comp()
{ return static_cast<key_compare &>(*this); }
- template<class A, class B>
- bool operator()(const A &a, const B &b) const
- { return key_compare::operator()(KeyOfValue()(a), KeyOfValue()(b)); }
+ template<class T>
+ struct is_key
+ {
+ static const bool value = is_same<const T, const key_type>::value;
+ };
+
+ template<class T>
+ typename enable_if_c<is_key<T>::value, const key_type &>::type
+ key_forward(const T &key) const
+ { return key; }
+
+ template<class T>
+ typename enable_if_c<!is_key<T>::value, const key_type &>::type
+ key_forward(const T &key) const
+ { return KeyOfValue()(key); }
+
+ template<class KeyType, class KeyType2>
+ bool operator()(const KeyType &key1, const KeyType2 &key2) const
+ { return key_compare::operator()(this->key_forward(key1), this->key_forward(key2)); }
};
template<class VoidPointer>
@@ -296,17 +312,29 @@
struct key_node_compare
: private KeyValueCompare
{
- key_node_compare(KeyValueCompare comp)
+ key_node_compare(const KeyValueCompare &comp)
: KeyValueCompare(comp)
{}
-
- template<class KeyType>
- bool operator()(const Node &n, const KeyType &k) const
- { return KeyValueCompare::operator()(n.get_data(), k); }
-
- template<class KeyType>
- bool operator()(const KeyType &k, const Node &n) const
- { return KeyValueCompare::operator()(k, n.get_data()); }
+
+ template<class T>
+ struct is_node
+ {
+ static const bool value = is_same<T, Node>::value;
+ };
+
+ template<class T>
+ typename enable_if_c<is_node<T>::value, const value_type &>::type
+ key_forward(const T &node) const
+ { return node.get_data(); }
+
+ template<class T>
+ typename enable_if_c<!is_node<T>::value, const T &>::type
+ key_forward(const T &key) const
+ { return key; }
+
+ template<class KeyType, class KeyType2>
+ bool operator()(const KeyType &key1, const KeyType2 &key2) const
+ { return KeyValueCompare::operator()(this->key_forward(key1), this->key_forward(key2)); }
};
typedef key_node_compare<value_compare> KeyNodeCompare;
Modified: trunk/boost/interprocess/containers/container/detail/type_traits.hpp
==============================================================================
--- trunk/boost/interprocess/containers/container/detail/type_traits.hpp (original)
+++ trunk/boost/interprocess/containers/container/detail/type_traits.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -21,6 +21,8 @@
#include "config_begin.hpp"
+#include <boost/move/move.hpp>
+
namespace boost {
namespace container {
namespace containers_detail {
@@ -81,6 +83,24 @@
typedef T type;
};
+#ifndef BOOST_NO_RVALUE_REFERENCES
+
+template<class T>
+struct remove_reference<T&&>
+{
+ typedef T type;
+};
+
+#else
+
+template<class T>
+struct remove_reference< ::boost::rv<T> >
+{
+ typedef T type;
+};
+
+#endif
+
template<class T>
struct is_reference
{
@@ -156,11 +176,28 @@
static const bool value = sizeof(yes_type) == sizeof(is_same_tester(t,u));
};
+template<class T>
+struct remove_const
+{
+ typedef T type;
+};
+
+template<class T>
+struct remove_const< const T>
+{
+ typedef T type;
+};
+
+template<class T>
+struct remove_ref_const
+{
+ typedef typename remove_const< typename remove_reference<T>::type >::type type;
+};
+
} // namespace containers_detail
} //namespace container {
} //namespace boost {
-#endif //#ifndef BOOST_CONTAINERS_CONTAINER_DETAIL_TYPE_TRAITS_HPP
-
#include INCLUDE_BOOST_CONTAINER_DETAIL_CONFIG_END_HPP
+#endif //#ifndef BOOST_CONTAINERS_CONTAINER_DETAIL_TYPE_TRAITS_HPP
Modified: trunk/boost/interprocess/containers/container/detail/version_type.hpp
==============================================================================
--- trunk/boost/interprocess/containers/container/detail/version_type.hpp (original)
+++ trunk/boost/interprocess/containers/container/detail/version_type.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -21,7 +21,6 @@
#include INCLUDE_BOOST_CONTAINER_DETAIL_MPL_HPP
#include INCLUDE_BOOST_CONTAINER_DETAIL_TYPE_TRAITS_HPP
-
namespace boost{
namespace container {
namespace containers_detail {
@@ -88,4 +87,6 @@
} //namespace container {
} //namespace boost{
+#include "config_end.hpp"
+
#endif //#define BOOST_CONTAINERS_DETAIL_VERSION_TYPE_HPP
Modified: trunk/boost/interprocess/containers/container/stable_vector.hpp
==============================================================================
--- trunk/boost/interprocess/containers/container/stable_vector.hpp (original)
+++ trunk/boost/interprocess/containers/container/stable_vector.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -177,10 +177,14 @@
typedef typename boost::pointer_to_other
<Pointer, void>::type void_ptr;
+ typedef typename boost::pointer_to_other
+ <Pointer, const void>::type const_void_ptr;
typedef node_type<void_ptr, T> node_type_t;
typedef typename boost::pointer_to_other
<void_ptr, node_type_t>::type node_type_ptr_t;
typedef typename boost::pointer_to_other
+ <void_ptr, const node_type_t>::type const_node_type_ptr_t;
+ typedef typename boost::pointer_to_other
<void_ptr, void_ptr>::type void_ptr_ptr;
friend class iterator<T, const T, typename boost::pointer_to_other<Pointer, T>::type>;
@@ -205,13 +209,19 @@
{}
private:
- static node_type_ptr_t node_ptr_cast(void_ptr p)
+ static node_type_ptr_t node_ptr_cast(const void_ptr &p)
{
using boost::get_pointer;
return node_type_ptr_t(static_cast<node_type_t*>(stable_vector_detail::get_pointer(p)));
}
- static void_ptr_ptr void_ptr_ptr_cast(void_ptr p)
+ static const_node_type_ptr_t node_ptr_cast(const const_void_ptr &p)
+ {
+ using boost::get_pointer;
+ return const_node_type_ptr_t(static_cast<const node_type_t*>(stable_vector_detail::get_pointer(p)));
+ }
+
+ static void_ptr_ptr void_ptr_ptr_cast(const void_ptr &p)
{
using boost::get_pointer;
return void_ptr_ptr(static_cast<void_ptr*>(stable_vector_detail::get_pointer(p)));
@@ -261,9 +271,9 @@
return *this;
}
- iterator operator+(difference_type off) const
+ friend iterator operator+(const iterator &left, difference_type off)
{
- iterator tmp(*this);
+ iterator tmp(left);
tmp += off;
return tmp;
}
@@ -278,38 +288,36 @@
iterator& operator-=(difference_type off)
{ *this += -off; return *this; }
- iterator operator-(difference_type off) const
+ friend iterator operator-(const iterator &left, difference_type off)
{
- iterator tmp(*this);
+ iterator tmp(left);
tmp -= off;
return tmp;
}
- difference_type operator-(const iterator& right) const
+ friend difference_type operator-(const iterator& left, const iterator& right)
{
- void_ptr_ptr p1 = void_ptr_ptr_cast(this->pn->up);
- void_ptr_ptr p2 = void_ptr_ptr_cast(right.pn->up);
- return p1 - p2;
+ return void_ptr_ptr_cast(left.pn->up) - void_ptr_ptr_cast(right.pn->up);
}
//Comparison operators
- bool operator== (const iterator& r) const
- { return pn == r.pn; }
+ friend bool operator== (const iterator& l, const iterator& r)
+ { return l.pn == r.pn; }
- bool operator!= (const iterator& r) const
- { return pn != r.pn; }
+ friend bool operator!= (const iterator& l, const iterator& r)
+ { return l.pn != r.pn; }
- bool operator< (const iterator& r) const
- { return void_ptr_ptr_cast(pn->up) < void_ptr_ptr_cast(r.pn->up); }
+ friend bool operator< (const iterator& l, const iterator& r)
+ { return void_ptr_ptr_cast(l.pn->up) < void_ptr_ptr_cast(r.pn->up); }
- bool operator<= (const iterator& r) const
- { return void_ptr_ptr_cast(pn->up) <= void_ptr_ptr_cast(r.pn->up); }
+ friend bool operator<= (const iterator& l, const iterator& r)
+ { return void_ptr_ptr_cast(l.pn->up) <= void_ptr_ptr_cast(r.pn->up); }
- bool operator> (const iterator& r) const
- { return void_ptr_ptr_cast(pn->up) > void_ptr_ptr_cast(r.pn->up); }
+ friend bool operator> (const iterator& l, const iterator& r)
+ { return void_ptr_ptr_cast(l.pn->up) > void_ptr_ptr_cast(r.pn->up); }
- bool operator>= (const iterator& r) const
- { return void_ptr_ptr_cast(pn->up) >= void_ptr_ptr_cast(r.pn->up); }
+ friend bool operator>= (const iterator& l, const iterator& r)
+ { return void_ptr_ptr_cast(l.pn->up) >= void_ptr_ptr_cast(r.pn->up); }
node_type_ptr_t pn;
};
@@ -379,8 +387,12 @@
move_const_ref_type<T>::type insert_const_ref_type;
typedef typename Allocator::template
rebind<void>::other::pointer void_ptr;
+ typedef typename boost::pointer_to_other
+ <void_ptr, const void>::type const_void_ptr;
typedef typename Allocator::template
rebind<void_ptr>::other::pointer void_ptr_ptr;
+ typedef typename boost::pointer_to_other
+ <void_ptr, const void_ptr>::type const_void_ptr_ptr;
typedef stable_vector_detail::node_type
<void_ptr, T> node_type_t;
typedef typename Allocator::template
@@ -456,6 +468,12 @@
private:
BOOST_COPYABLE_AND_MOVABLE(stable_vector)
static const size_type ExtraPointers = 3;
+ //This container stores metadata at the end of the void_ptr vector with additional 3 pointers:
+ // back() is impl.back() - ExtraPointers;
+ // end node index is impl.end()[-3]
+ // Node cache first is impl.end()[-2];
+ // Node cache last is *impl.back();
+
typedef typename stable_vector_detail::
select_multiallocation_chain
< node_allocator_type
@@ -812,11 +830,11 @@
iterator erase(const_iterator position)
{
STABLE_VECTOR_CHECK_INVARIANT;
- difference_type d=position-this->cbegin();
- impl_iterator it=impl.begin()+d;
+ difference_type d = position - this->cbegin();
+ impl_iterator it = impl.begin() + d;
this->delete_node(*it);
- impl.erase(it);
- this->align_nodes(impl.begin()+d,get_last_align());
+ it = impl.erase(it);
+ this->align_nodes(it, get_last_align());
return this->begin()+d;
}
@@ -847,17 +865,17 @@
void clear_pool(allocator_v1)
{
if(!impl.empty() && impl.back()){
- void_ptr &p1 = *(impl.end()-2);
- void_ptr &p2 = impl.back();
+ void_ptr &pool_first_ref = impl.end()[-2];
+ void_ptr &pool_last_ref = impl.back();
multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), p1, p2, this->internal_data.pool_size);
+ holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, this->internal_data.pool_size);
while(!holder.empty()){
node_type_ptr_t n = holder.front();
holder.pop_front();
this->deallocate_one(n);
}
- p1 = p2 = 0;
+ pool_first_ref = pool_last_ref = 0;
this->internal_data.pool_size = 0;
}
}
@@ -866,12 +884,12 @@
{
if(!impl.empty() && impl.back()){
- void_ptr &p1 = *(impl.end()-2);
- void_ptr &p2 = impl.back();
+ void_ptr &pool_first_ref = impl.end()[-2];
+ void_ptr &pool_last_ref = impl.back();
multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), p1, p2, internal_data.pool_size);
+ holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
get_al().deallocate_individual(boost::move(holder));
- p1 = p2 = 0;
+ pool_first_ref = pool_last_ref = 0;
this->internal_data.pool_size = 0;
}
}
@@ -896,30 +914,30 @@
void add_to_pool(size_type n, allocator_v2)
{
- void_ptr &p1 = *(impl.end()-2);
- void_ptr &p2 = impl.back();
+ void_ptr &pool_first_ref = impl.end()[-2];
+ void_ptr &pool_last_ref = impl.back();
multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), p1, p2, internal_data.pool_size);
+ holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
//BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled<multiallocation_chain>::value == true));
multiallocation_chain m (get_al().allocate_individual(n));
holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n);
this->internal_data.pool_size += n;
std::pair<void_ptr, void_ptr> data(holder.extract_data());
- p1 = data.first;
- p2 = data.second;
+ pool_first_ref = data.first;
+ pool_last_ref = data.second;
}
void put_in_pool(node_type_ptr_t p)
{
- void_ptr &p1 = *(impl.end()-2);
- void_ptr &p2 = impl.back();
+ void_ptr &pool_first_ref = impl.end()[-2];
+ void_ptr &pool_last_ref = impl.back();
multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), p1, p2, internal_data.pool_size);
+ holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
holder.push_front(p);
++this->internal_data.pool_size;
std::pair<void_ptr, void_ptr> ret(holder.extract_data());
- p1 = ret.first;
- p2 = ret.second;
+ pool_first_ref = ret.first;
+ pool_last_ref = ret.second;
}
node_type_ptr_t get_from_pool()
@@ -928,20 +946,20 @@
return node_type_ptr_t(0);
}
else{
- void_ptr &p1 = *(impl.end()-2);
- void_ptr &p2 = impl.back();
+ void_ptr &pool_first_ref = impl.end()[-2];
+ void_ptr &pool_last_ref = impl.back();
multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), p1, p2, internal_data.pool_size);
+ holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
node_type_ptr_t ret = holder.front();
holder.pop_front();
--this->internal_data.pool_size;
if(!internal_data.pool_size){
- p1 = p2 = 0;
+ pool_first_ref = pool_last_ref = void_ptr(0);
}
else{
std::pair<void_ptr, void_ptr> data(holder.extract_data());
- p1 = data.first;
- p2 = data.second;
+ pool_first_ref = data.first;
+ pool_last_ref = data.second;
}
return ret;
}
@@ -992,8 +1010,8 @@
impl_iterator it1(impl.begin() + d1), it2(impl.begin() + d2);
for(impl_iterator it = it1; it != it2; ++it)
this->delete_node(*it);
- impl.erase(it1, it2);
- this->align_nodes(impl.begin() + d1, get_last_align());
+ impl_iterator e = impl.erase(it1, it2);
+ this->align_nodes(e, get_last_align());
}
return iterator(this->begin() + d1);
}
@@ -1018,19 +1036,19 @@
return priv_erase(first, last, allocator_v1());
}
- static node_type_ptr_t node_ptr_cast(void_ptr p)
+ static node_type_ptr_t node_ptr_cast(const void_ptr &p)
{
using boost::get_pointer;
return node_type_ptr_t(static_cast<node_type_t*>(stable_vector_detail::get_pointer(p)));
}
- static node_type_base_ptr_t node_base_ptr_cast(void_ptr p)
+ static node_type_base_ptr_t node_base_ptr_cast(const void_ptr &p)
{
using boost::get_pointer;
return node_type_base_ptr_t(static_cast<node_type_base_t*>(stable_vector_detail::get_pointer(p)));
}
- static value_type& value(void_ptr p)
+ static value_type& value(const void_ptr &p)
{
return node_ptr_cast(p)->value;
}
@@ -1065,7 +1083,7 @@
}
template<class Iter>
- void_ptr new_node(void_ptr up, Iter it)
+ void_ptr new_node(const void_ptr &up, Iter it)
{
node_type_ptr_t p = this->allocate_one();
try{
@@ -1079,14 +1097,14 @@
return p;
}
- void delete_node(void_ptr p)
+ void delete_node(const void_ptr &p)
{
node_type_ptr_t n(node_ptr_cast(p));
n->~node_type_t();
this->put_in_pool(n);
}
- static void align_nodes(impl_iterator first,impl_iterator last)
+ static void align_nodes(impl_iterator first, impl_iterator last)
{
while(first!=last){
node_ptr_cast(*first)->up = void_ptr(&*first);
@@ -1136,14 +1154,14 @@
size_type i=0;
try{
while(first!=last){
- *(it + i) = this->new_node(void_ptr((void*)(&*(it + i))), first);
+ it[i] = this->new_node(void_ptr_ptr(&it[i]), first);
++first;
++i;
}
}
catch(...){
- impl.erase(it + i, it + n);
- this->align_nodes(it + i, get_last_align());
+ impl_iterator e = impl.erase(it + i, it + n);
+ this->align_nodes(e, get_last_align());
throw;
}
}
@@ -1161,17 +1179,17 @@
mem.pop_front();
//This can throw
boost::container::construct_in_place(&*p, first);
- p->set_pointer(void_ptr((void*)(&*(it + i))));
+ p->set_pointer(void_ptr_ptr(&it[i]));
++first;
- *(it + i) = p;
+ it[i] = p;
++i;
}
}
catch(...){
get_al().deallocate_one(p);
get_al().deallocate_many(boost::move(mem));
- impl.erase(it+i, it+n);
- this->align_nodes(it+i,get_last_align());
+ impl_iterator e = impl.erase(it+i, it+n);
+ this->align_nodes(e, get_last_align());
throw;
}
}
@@ -1190,16 +1208,16 @@
}
//This can throw
boost::container::construct_in_place(&*p, first);
- p->set_pointer(void_ptr(&*(it+i)));
+ p->set_pointer(void_ptr_ptr(&it[i]));
++first;
- *(it+i)=p;
+ it[i]=p;
++i;
}
}
catch(...){
put_in_pool(p);
- impl.erase(it+i,it+n);
- this->align_nodes(it+i,get_last_align());
+ impl_iterator e = impl.erase(it+i, it+n);
+ this->align_nodes(e, get_last_align());
throw;
}
}
@@ -1228,9 +1246,10 @@
if(get_end_node() != *(impl.end() - ExtraPointers)){
return false;
}
- for(const_impl_iterator it=impl.begin(),it_end=get_last_align();it!=it_end;++it){
- if(node_ptr_cast(*it)->up != &*it)
- return false;
+ for(const_impl_iterator it = impl.begin(), it_end = get_last_align(); it != it_end; ++it){
+ if(const_void_ptr(node_ptr_cast(*it)->up) !=
+ const_void_ptr(const_void_ptr_ptr(&*it)))
+ return false;
}
size_type n = capacity()-size();
const void_ptr &pool_head = impl.back();
@@ -1238,7 +1257,7 @@
node_type_ptr_t p = node_ptr_cast(pool_head);
while(p){
++num_pool;
- p = p->up;
+ p = node_ptr_cast(p->up);
}
return n >= num_pool;
}
Modified: trunk/boost/interprocess/containers/pair.hpp
==============================================================================
--- trunk/boost/interprocess/containers/pair.hpp (original)
+++ trunk/boost/interprocess/containers/pair.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -23,6 +23,7 @@
namespace interprocess {
using boost::container::containers_detail::pair;
+using boost::container::containers_detail::piecewise_construct;
} //namespace interprocess {
} //namespace boost {
Modified: trunk/boost/interprocess/detail/intersegment_ptr.hpp
==============================================================================
--- trunk/boost/interprocess/detail/intersegment_ptr.hpp (original)
+++ trunk/boost/interprocess/detail/intersegment_ptr.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -1037,5 +1037,6 @@
#endif
-#endif //#ifndef BOOST_INTERPROCESS_INTERSEGMENT_PTR_HPP
+#include <boost/interprocess/detail/config_end.hpp>
+#endif //#ifndef BOOST_INTERPROCESS_INTERSEGMENT_PTR_HPP
Modified: trunk/boost/interprocess/detail/managed_open_or_create_impl.hpp
==============================================================================
--- trunk/boost/interprocess/detail/managed_open_or_create_impl.hpp (original)
+++ trunk/boost/interprocess/detail/managed_open_or_create_impl.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -11,6 +11,7 @@
#ifndef BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_IMPL
#define BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_IMPL
+#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/os_thread_functions.hpp>
#include <boost/interprocess/detail/os_file_functions.hpp>
#include <boost/interprocess/creation_tags.hpp>
@@ -455,4 +456,6 @@
} //namespace interprocess {
} //namespace boost {
+#include <boost/interprocess/detail/config_end.hpp>
+
#endif //#ifndef BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_IMPL
Modified: trunk/boost/interprocess/offset_ptr.hpp
==============================================================================
--- trunk/boost/interprocess/offset_ptr.hpp (original)
+++ trunk/boost/interprocess/offset_ptr.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -112,11 +112,11 @@
union internal_type{
OffsetType m_offset; //Distance between this object and pointed address
-/* typename ::boost::aligned_storage
+ typename ::boost::aligned_storage
< sizeof(OffsetType)
, (OffsetAlignment == offset_type_alignment) ?
::boost::alignment_of<OffsetType>::value : OffsetAlignment
- >::type alignment_helper;*/
+ >::type alignment_helper;
} internal;
/// @endcond
Modified: trunk/boost/interprocess/smart_ptr/enable_shared_from_this.hpp
==============================================================================
--- trunk/boost/interprocess/smart_ptr/enable_shared_from_this.hpp (original)
+++ trunk/boost/interprocess/smart_ptr/enable_shared_from_this.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -14,8 +14,8 @@
#ifndef BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
#define BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
-#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
#include <boost/assert.hpp>
#include <boost/interprocess/smart_ptr/weak_ptr.hpp>
Modified: trunk/boost/interprocess/sync/emulation/mutex.hpp
==============================================================================
--- trunk/boost/interprocess/sync/emulation/mutex.hpp (original)
+++ trunk/boost/interprocess/sync/emulation/mutex.hpp 2011-03-28 04:53:14 EDT (Mon, 28 Mar 2011)
@@ -111,4 +111,6 @@
} //namespace interprocess {
} //namespace boost {
+#include <boost/interprocess/detail/config_end.hpp>
+
#endif //BOOST_INTERPROCESS_DETAIL_EMULATION_MUTEX_HPP
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk