Compare commits

..

4 Commits

Author SHA1 Message Date
Glen Fernandes
70664ea403 Merge branch 'develop' 2017-06-04 10:41:13 -04:00
Glen Fernandes
a2a85b57d4 Merge pull request #13 from glenfe/develop
Use pointer_traits.to_address instead of addressof(*p)
2017-05-29 18:41:47 -04:00
Glen Fernandes
ef8c59c4a6 Use pointer_traits.to_address instead of addressof(*p) 2017-05-29 18:39:33 -04:00
Rene Rivera
31aa9939b3 Add, and update, documentation build targets. 2016-10-07 23:07:33 -05:00
3 changed files with 25 additions and 16 deletions

View File

@@ -666,7 +666,7 @@ public:
break;
}
if (is_uninitialized(dest)) {
boost::container::allocator_traits<Alloc>::construct(m_alloc, boost::addressof(*dest), boost::move_if_noexcept(*src));
boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(dest), boost::move_if_noexcept(*src));
++constructed;
} else {
value_type tmp = boost::move_if_noexcept(*src);
@@ -1422,7 +1422,7 @@ private:
increment(m_last);
m_first = m_last;
} else {
boost::container::allocator_traits<Alloc>::construct(m_alloc, boost::addressof(*m_last), static_cast<ValT>(item));
boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(m_last), static_cast<ValT>(item));
increment(m_last);
++m_size;
}
@@ -1439,7 +1439,7 @@ private:
m_last = m_first;
} else {
decrement(m_first);
boost::container::allocator_traits<Alloc>::construct(m_alloc, boost::addressof(*m_first), static_cast<ValT>(item));
boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(m_first), static_cast<ValT>(item));
++m_size;
}
} BOOST_CATCH(...) {
@@ -2414,7 +2414,7 @@ private:
*/
void construct_or_replace(bool construct, pointer pos, param_value_type item) {
if (construct)
boost::container::allocator_traits<Alloc>::construct(m_alloc, boost::addressof(*pos), item);
boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(pos), item);
else
replace(pos, item);
}
@@ -2426,14 +2426,14 @@ private:
*/
void construct_or_replace(bool construct, pointer pos, rvalue_type item) {
if (construct)
boost::container::allocator_traits<Alloc>::construct(m_alloc, boost::addressof(*pos), boost::move(item));
boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(pos), boost::move(item));
else
replace(pos, boost::move(item));
}
//! Destroy an item.
void destroy_item(pointer p) {
boost::container::allocator_traits<Alloc>::destroy(m_alloc, boost::addressof(*p));
boost::container::allocator_traits<Alloc>::destroy(m_alloc, cb_details::to_address(p));
#if BOOST_CB_ENABLE_DEBUG
invalidate_iterators(iterator(this, p));
cb_details::do_fill_uninitialized_memory(p, sizeof(value_type));
@@ -2566,7 +2566,7 @@ private:
if (buffer_capacity == 0)
return;
while (first != last && !full()) {
boost::container::allocator_traits<Alloc>::construct(m_alloc, boost::addressof(*m_last), *first++);
boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(m_last), *first++);
increment(m_last);
++m_size;
}
@@ -2831,7 +2831,7 @@ private:
pointer p = m_last;
BOOST_TRY {
for (; ii < construct; ++ii, increment(p))
boost::container::allocator_traits<Alloc>::construct(m_alloc, boost::addressof(*p), *wrapper());
boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(p), *wrapper());
for (;ii < n; ++ii, increment(p))
replace(p, *wrapper());
} BOOST_CATCH(...) {
@@ -2925,7 +2925,7 @@ private:
for (;ii > construct; --ii, increment(p))
replace(p, *wrapper());
for (; ii > 0; --ii, increment(p))
boost::container::allocator_traits<Alloc>::construct(m_alloc, boost::addressof(*p), *wrapper());
boost::container::allocator_traits<Alloc>::construct(m_alloc, cb_details::to_address(p), *wrapper());
} BOOST_CATCH(...) {
size_type constructed = ii < construct ? construct - ii : 0;
m_last = add(m_last, constructed);

View File

@@ -1,7 +1,7 @@
// Helper classes and functions for the circular buffer.
// Copyright (c) 2003-2008 Jan Gaspar
// Copyright (c) 2014 Glen Fernandes // C++11 allocator model support.
// Copyright (c) 2014 Glen Joseph Fernandes // C++11 allocator model support.
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -16,6 +16,7 @@
#include <boost/throw_exception.hpp>
#include <boost/container/allocator_traits.hpp>
#include <boost/core/pointer_traits.hpp>
#include <boost/move/move.hpp>
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
#include <boost/utility/addressof.hpp>
@@ -34,6 +35,13 @@ namespace boost {
namespace cb_details {
template<class Pointer>
inline typename boost::pointer_traits<Pointer>::element_type*
to_address(Pointer p) BOOST_NOEXCEPT
{
return boost::pointer_traits<Pointer>::to_address(p);
}
template <class Traits> struct nonconst_traits;
template<class ForwardIterator, class Diff, class T, class Alloc>
@@ -435,10 +443,10 @@ inline ForwardIterator uninitialized_copy(InputIterator first, InputIterator las
ForwardIterator next = dest;
BOOST_TRY {
for (; first != last; ++first, ++dest)
boost::container::allocator_traits<Alloc>::construct(a, boost::addressof(*dest), *first);
boost::container::allocator_traits<Alloc>::construct(a, cb_details::to_address(dest), *first);
} BOOST_CATCH(...) {
for (; next != dest; ++next)
boost::container::allocator_traits<Alloc>::destroy(a, boost::addressof(*next));
boost::container::allocator_traits<Alloc>::destroy(a, cb_details::to_address(next));
BOOST_RETHROW
}
BOOST_CATCH_END
@@ -449,7 +457,7 @@ template<class InputIterator, class ForwardIterator, class Alloc>
ForwardIterator uninitialized_move_if_noexcept_impl(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a,
true_type) {
for (; first != last; ++first, ++dest)
boost::container::allocator_traits<Alloc>::construct(a, boost::addressof(*dest), boost::move(*first));
boost::container::allocator_traits<Alloc>::construct(a, cb_details::to_address(dest), boost::move(*first));
return dest;
}
@@ -478,10 +486,10 @@ inline void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const
ForwardIterator next = first;
BOOST_TRY {
for (; n > 0; ++first, --n)
boost::container::allocator_traits<Alloc>::construct(alloc, boost::addressof(*first), item);
boost::container::allocator_traits<Alloc>::construct(alloc, cb_details::to_address(first), item);
} BOOST_CATCH(...) {
for (; next != first; ++next)
boost::container::allocator_traits<Alloc>::destroy(alloc, boost::addressof(*next));
boost::container::allocator_traits<Alloc>::destroy(alloc, cb_details::to_address(next));
BOOST_RETHROW
}
BOOST_CATCH_END

View File

@@ -2,7 +2,7 @@
// Copyright (c) 2003-2008 Jan Gaspar
// Copyright (c) 2013 Antony Polukhin
// Copyright (c) 2014 Glen Fernandes // C++11 allocator model support.
// Copyright (c) 2014 Glen Joseph Fernandes // C++11 allocator model support.
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -186,6 +186,7 @@ private:
pointer_ operator++(int) { pointer_ p = *this; ++hidden_ptr_; return p; }
pointer_ operator--(int) { pointer_ p = *this; --hidden_ptr_; return p; }
U& operator*() const { return *hidden_ptr_; }
U* operator->() const { return hidden_ptr_; }
U* hidden_ptr_;
};