mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
- Update changelog to Pull #45
- Cleanup in shared_ptr_test and named_proxy - Reuse Boost.Container transform_iterator instead of using own.
This commit is contained in:
@@ -6762,6 +6762,12 @@ thank them:
|
||||
|
||||
[section:release_notes Release Notes]
|
||||
|
||||
[section:release_notes_boost_1_67_00 Boost 1.67 Release]
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/interprocess/pull/45 GitHub Pull #45 (['"Make intrusive_ptr move constructible/assignable"])].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:release_notes_boost_1_66_00 Boost 1.66 Release]
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/interprocess/pull/41 GitHub Pull #41 (['"Data race in boost::interprocess::rbtree_best_fit"])].
|
||||
|
||||
@@ -274,7 +274,7 @@ class named_proxy
|
||||
T *operator()( BOOST_MOVE_UREF##N ) const\
|
||||
{\
|
||||
typedef typename if_c<is_iterator \
|
||||
, CtorIt##N<T BOOST_MOVE_I##N BOOST_MOVE_TARG##N> \
|
||||
, CtorIt##N <T BOOST_MOVE_I##N BOOST_MOVE_TARG##N> \
|
||||
, CtorArg##N<T BOOST_MOVE_I##N BOOST_MOVE_TARG##N> \
|
||||
>::type ctor_obj_t;\
|
||||
ctor_obj_t ctor_obj = ctor_obj_t( BOOST_MOVE_FWD##N );\
|
||||
|
||||
@@ -27,170 +27,14 @@
|
||||
|
||||
// interprocess
|
||||
#include <boost/interprocess/interprocess_fwd.hpp>
|
||||
// interprocess/detail
|
||||
#include <boost/interprocess/detail/type_traits.hpp>
|
||||
// move/detail
|
||||
#include <boost/container/detail/iterator.hpp>
|
||||
// container/detail
|
||||
#include <boost/container/detail/transform_iterator.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace interprocess {
|
||||
|
||||
template <class PseudoReference>
|
||||
struct operator_arrow_proxy
|
||||
{
|
||||
operator_arrow_proxy(const PseudoReference &px)
|
||||
: m_value(px)
|
||||
{}
|
||||
|
||||
PseudoReference* operator->() const { return &m_value; }
|
||||
// This function is needed for MWCW and BCC, which won't call operator->
|
||||
// again automatically per 13.3.1.2 para 8
|
||||
// operator T*() const { return &m_value; }
|
||||
mutable PseudoReference m_value;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct operator_arrow_proxy<T&>
|
||||
{
|
||||
operator_arrow_proxy(T &px)
|
||||
: m_value(px)
|
||||
{}
|
||||
|
||||
T* operator->() const { return const_cast<T*>(&m_value); }
|
||||
// This function is needed for MWCW and BCC, which won't call operator->
|
||||
// again automatically per 13.3.1.2 para 8
|
||||
// operator T*() const { return &m_value; }
|
||||
T &m_value;
|
||||
};
|
||||
|
||||
template <class Iterator, class UnaryFunction>
|
||||
class transform_iterator
|
||||
: public UnaryFunction
|
||||
{
|
||||
public:
|
||||
typedef typename ::boost::container::iterator_traits<Iterator>::iterator_category iterator_category;
|
||||
typedef typename ipcdetail::remove_reference<typename UnaryFunction::result_type>::type value_type;
|
||||
typedef typename ::boost::container::iterator_traits<Iterator>::difference_type difference_type;
|
||||
typedef operator_arrow_proxy<typename UnaryFunction::result_type> pointer;
|
||||
typedef typename UnaryFunction::result_type reference;
|
||||
|
||||
explicit transform_iterator(const Iterator &it, const UnaryFunction &f = UnaryFunction())
|
||||
: UnaryFunction(f), m_it(it)
|
||||
{}
|
||||
|
||||
explicit transform_iterator()
|
||||
: UnaryFunction(), m_it()
|
||||
{}
|
||||
|
||||
//Constructors
|
||||
transform_iterator& operator++()
|
||||
{ increment(); return *this; }
|
||||
|
||||
transform_iterator operator++(int)
|
||||
{
|
||||
transform_iterator result (*this);
|
||||
increment();
|
||||
return result;
|
||||
}
|
||||
|
||||
transform_iterator& operator--()
|
||||
{ decrement(); return *this; }
|
||||
|
||||
transform_iterator operator--(int)
|
||||
{
|
||||
transform_iterator result (*this);
|
||||
decrement();
|
||||
return result;
|
||||
}
|
||||
|
||||
friend bool operator== (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return i.equal(i2); }
|
||||
|
||||
friend bool operator!= (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return !(i == i2); }
|
||||
|
||||
friend bool operator< (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return i < i2; }
|
||||
|
||||
friend bool operator> (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return i2 < i; }
|
||||
|
||||
friend bool operator<= (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return !(i > i2); }
|
||||
|
||||
friend bool operator>= (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return !(i < i2); }
|
||||
|
||||
friend difference_type operator- (const transform_iterator& i, const transform_iterator& i2)
|
||||
{ return i2.distance_to(i); }
|
||||
|
||||
//Arithmetic
|
||||
transform_iterator& operator+=(difference_type off)
|
||||
{ this->advance(off); return *this; }
|
||||
|
||||
transform_iterator operator+(difference_type off) const
|
||||
{
|
||||
transform_iterator other(*this);
|
||||
other.advance(off);
|
||||
return other;
|
||||
}
|
||||
|
||||
friend transform_iterator operator+(difference_type off, const transform_iterator& right)
|
||||
{ return right + off; }
|
||||
|
||||
transform_iterator& operator-=(difference_type off)
|
||||
{ this->advance(-off); return *this; }
|
||||
|
||||
transform_iterator operator-(difference_type off) const
|
||||
{ return *this + (-off); }
|
||||
|
||||
typename UnaryFunction::result_type operator*() const
|
||||
{ return dereference(); }
|
||||
|
||||
typename UnaryFunction::result_type operator[](difference_type off) const
|
||||
{ return UnaryFunction::operator()(m_it[off]); }
|
||||
|
||||
operator_arrow_proxy<typename UnaryFunction::result_type>
|
||||
operator->() const
|
||||
{ return operator_arrow_proxy<typename UnaryFunction::result_type>(dereference()); }
|
||||
|
||||
Iterator & base()
|
||||
{ return m_it; }
|
||||
|
||||
const Iterator & base() const
|
||||
{ return m_it; }
|
||||
|
||||
private:
|
||||
Iterator m_it;
|
||||
|
||||
void increment()
|
||||
{ ++m_it; }
|
||||
|
||||
void decrement()
|
||||
{ --m_it; }
|
||||
|
||||
bool equal(const transform_iterator &other) const
|
||||
{ return m_it == other.m_it; }
|
||||
|
||||
bool less(const transform_iterator &other) const
|
||||
{ return other.m_it < m_it; }
|
||||
|
||||
typename UnaryFunction::result_type dereference() const
|
||||
{ return UnaryFunction::operator()(*m_it); }
|
||||
|
||||
void advance(difference_type n)
|
||||
{ ::boost::container::iterator_advance(m_it, n); }
|
||||
|
||||
difference_type distance_to(const transform_iterator &other)const
|
||||
{ return ::boost::container::iterator_distance(other.m_it, m_it); }
|
||||
};
|
||||
|
||||
template <class Iterator, class UnaryFunc>
|
||||
transform_iterator<Iterator, UnaryFunc>
|
||||
make_transform_iterator(Iterator it, UnaryFunc fun)
|
||||
{
|
||||
return transform_iterator<Iterator, UnaryFunc>(it, fun);
|
||||
}
|
||||
using boost::container::make_transform_iterator;
|
||||
using boost::container::transform_iterator;
|
||||
|
||||
} //namespace interprocess {
|
||||
} //namespace boost {
|
||||
|
||||
@@ -630,7 +630,7 @@ class segment_manager
|
||||
//!the named allocations performed in this segment manager
|
||||
const_named_iterator named_begin() const
|
||||
{
|
||||
return make_transform_iterator
|
||||
return (make_transform_iterator)
|
||||
(m_header.m_named_index.begin(), named_transform());
|
||||
}
|
||||
|
||||
@@ -638,7 +638,7 @@ class segment_manager
|
||||
//!the named allocations performed in this segment manager
|
||||
const_named_iterator named_end() const
|
||||
{
|
||||
return make_transform_iterator
|
||||
return (make_transform_iterator)
|
||||
(m_header.m_named_index.end(), named_transform());
|
||||
}
|
||||
|
||||
@@ -646,7 +646,7 @@ class segment_manager
|
||||
//!the unique allocations performed in this segment manager
|
||||
const_unique_iterator unique_begin() const
|
||||
{
|
||||
return make_transform_iterator
|
||||
return (make_transform_iterator)
|
||||
(m_header.m_unique_index.begin(), unique_transform());
|
||||
}
|
||||
|
||||
@@ -654,7 +654,7 @@ class segment_manager
|
||||
//!the unique allocations performed in this segment manager
|
||||
const_unique_iterator unique_end() const
|
||||
{
|
||||
return make_transform_iterator
|
||||
return (make_transform_iterator)
|
||||
(m_header.m_unique_index.end(), unique_transform());
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,9 @@ class derived_class
|
||||
|
||||
int simple_test()
|
||||
{
|
||||
typedef allocator<base_class, managed_shared_memory::segment_manager>
|
||||
base_class_allocator;
|
||||
typedef deleter<base_class, managed_shared_memory::segment_manager>
|
||||
base_deleter_t;
|
||||
typedef managed_shared_memory::segment_manager segment_mngr_t;
|
||||
typedef allocator<base_class, segment_mngr_t> base_class_allocator;
|
||||
typedef deleter<base_class, segment_mngr_t> base_deleter_t;
|
||||
typedef shared_ptr<base_class, base_class_allocator, base_deleter_t> base_shared_ptr;
|
||||
|
||||
std::string process_name;
|
||||
@@ -97,35 +96,31 @@ int simple_test()
|
||||
|
||||
int string_shared_ptr_vector_insertion_test()
|
||||
{
|
||||
typedef managed_shared_memory::segment_manager segment_mngr_t;
|
||||
|
||||
//Allocator of chars
|
||||
typedef allocator<char, managed_shared_memory::segment_manager >
|
||||
char_allocator_t;
|
||||
typedef allocator<char, segment_mngr_t> char_allocator_t;
|
||||
|
||||
//A shared memory string class
|
||||
typedef basic_string<char, std::char_traits<char>,
|
||||
char_allocator_t> string_t;
|
||||
typedef basic_string<char, std::char_traits<char>, char_allocator_t> string_t;
|
||||
|
||||
//A shared memory string allocator
|
||||
typedef allocator<string_t, managed_shared_memory::segment_manager>
|
||||
string_allocator_t;
|
||||
typedef allocator<string_t, segment_mngr_t> string_allocator_t;
|
||||
|
||||
//A deleter for shared_ptr<> that erases a shared memory string
|
||||
typedef deleter<string_t, managed_shared_memory::segment_manager>
|
||||
string_deleter_t;
|
||||
typedef deleter<string_t, segment_mngr_t> string_deleter_t;
|
||||
|
||||
//A shared pointer that points to a shared memory string and its instantiation
|
||||
typedef shared_ptr<string_t, string_allocator_t, string_deleter_t> string_shared_ptr_t;
|
||||
|
||||
//An allocator for shared pointers to a string in shared memory
|
||||
typedef allocator<string_shared_ptr_t, managed_shared_memory::segment_manager>
|
||||
string_shared_ptr_allocator_t;
|
||||
typedef allocator<string_shared_ptr_t, segment_mngr_t> string_shared_ptr_allocator_t;
|
||||
|
||||
//A weak pointer that points to a shared memory string and its instantiation
|
||||
typedef weak_ptr<string_t, string_allocator_t, string_deleter_t> string_weak_ptr_t;
|
||||
|
||||
//An allocator for weak pointers to a string in shared memory
|
||||
typedef allocator<string_weak_ptr_t, managed_shared_memory::segment_manager >
|
||||
string_weak_ptr_allocator_t;
|
||||
typedef allocator<string_weak_ptr_t, segment_mngr_t > string_weak_ptr_allocator_t;
|
||||
|
||||
//A vector of shared pointers to strings (all in shared memory) and its instantiation
|
||||
typedef vector<string_shared_ptr_t, string_shared_ptr_allocator_t>
|
||||
@@ -156,8 +151,7 @@ int string_shared_ptr_vector_insertion_test()
|
||||
//Create a string in shared memory, to avoid leaks with exceptions use
|
||||
//scoped ptr until we store this pointer in the shared ptr
|
||||
scoped_ptr<string_t, string_deleter_t> scoped_string
|
||||
(shmem.construct<string_t>(anonymous_instance)(string_allocator),
|
||||
deleter);
|
||||
(shmem.construct<string_t>(anonymous_instance)(string_allocator), deleter);
|
||||
//Now construct a shared pointer to a string
|
||||
string_shared_ptr_t string_shared_ptr (scoped_string.get(),
|
||||
string_shared_ptr_allocator,
|
||||
@@ -262,6 +256,7 @@ int string_shared_ptr_vector_insertion_test()
|
||||
shared_memory_object::remove(process_name.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// This part is taken from shared_ptr_basic_test.cpp
|
||||
//
|
||||
@@ -402,21 +397,13 @@ void test_is_nonzero(shared_ptr<T, A, D> const & p)
|
||||
|
||||
int basic_shared_ptr_test()
|
||||
{
|
||||
typedef allocator<void, managed_shared_memory::segment_manager>
|
||||
v_allocator_t;
|
||||
|
||||
typedef deleter<X, managed_shared_memory::segment_manager>
|
||||
x_deleter_t;
|
||||
|
||||
typedef deleter<Y, managed_shared_memory::segment_manager>
|
||||
y_deleter_t;
|
||||
|
||||
typedef managed_shared_memory::segment_manager segment_mngr_t;
|
||||
typedef allocator<void, segment_mngr_t> v_allocator_t;
|
||||
typedef deleter<X, segment_mngr_t> x_deleter_t;
|
||||
typedef deleter<Y, segment_mngr_t> y_deleter_t;
|
||||
typedef shared_ptr<X, v_allocator_t, x_deleter_t> x_shared_ptr;
|
||||
|
||||
typedef shared_ptr<Y, v_allocator_t, y_deleter_t> y_shared_ptr;
|
||||
|
||||
typedef weak_ptr<X, v_allocator_t, x_deleter_t> x_weak_ptr;
|
||||
|
||||
typedef weak_ptr<Y, v_allocator_t, y_deleter_t> y_weak_ptr;
|
||||
|
||||
std::string process_name;
|
||||
@@ -557,11 +544,9 @@ struct alias_tester
|
||||
|
||||
void test_alias()
|
||||
{
|
||||
typedef allocator<void, managed_shared_memory::segment_manager>
|
||||
v_allocator_t;
|
||||
|
||||
typedef deleter<int, managed_shared_memory::segment_manager>
|
||||
int_deleter_t;
|
||||
typedef managed_shared_memory::segment_manager segment_mngr_t;
|
||||
typedef allocator<void, segment_mngr_t> v_allocator_t;
|
||||
typedef deleter<int, segment_mngr_t> int_deleter_t;
|
||||
|
||||
typedef shared_ptr<int, v_allocator_t, int_deleter_t> int_shared_ptr;
|
||||
typedef shared_ptr<const int, v_allocator_t, int_deleter_t> const_int_shared_ptr;
|
||||
|
||||
Reference in New Issue
Block a user