mirror of
https://github.com/boostorg/container.git
synced 2026-01-19 04:02:17 +00:00
Use operator_new_allocate/operator_delete_deallocate for test allocators
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <boost/container/uses_allocator.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/operator_new_helpers.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
|
||||
template<class T, unsigned int Id, bool HasTrueTypes = false>
|
||||
@@ -69,17 +70,10 @@ class propagation_test_allocator
|
||||
{ return std::size_t(-1); }
|
||||
|
||||
value_type* allocate(std::size_t count)
|
||||
{ return static_cast<value_type*>(::operator new(count * sizeof(value_type))); }
|
||||
{ return boost::container::dtl::operator_new_allocate<value_type>(count); }
|
||||
|
||||
void deallocate(value_type *ptr, std::size_t n)
|
||||
{
|
||||
(void)n;
|
||||
# if defined(__cpp_sized_deallocation)
|
||||
::operator delete((void*)ptr, n * sizeof(value_type));
|
||||
#else
|
||||
::operator delete((void*)ptr);
|
||||
# endif
|
||||
}
|
||||
{ return boost::container::dtl::operator_delete_deallocate<T>(ptr, n); }
|
||||
|
||||
bool m_move_contructed;
|
||||
bool m_move_assigned;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <boost/container/detail/multiallocation_chain.hpp>
|
||||
#include <boost/container/detail/type_traits.hpp>
|
||||
#include <boost/container/detail/version_type.hpp>
|
||||
#include <boost/container/detail/operator_new_helpers.hpp>
|
||||
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
@@ -59,18 +60,11 @@ class simple_allocator
|
||||
simple_allocator(const simple_allocator<U> &)
|
||||
{}
|
||||
|
||||
T* allocate(std::size_t n)
|
||||
{ return (T*) ::operator new(sizeof(T) * n); }
|
||||
value_type* allocate(std::size_t count)
|
||||
{ return boost::container::dtl::operator_new_allocate<value_type>(count); }
|
||||
|
||||
void deallocate(T *ptr, std::size_t n) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
(void)n;
|
||||
# if defined(__cpp_sized_deallocation)
|
||||
::operator delete((void*)ptr, n * sizeof(T));
|
||||
#else
|
||||
::operator delete((void*)ptr);
|
||||
# endif
|
||||
}
|
||||
void deallocate(value_type *ptr, std::size_t n)
|
||||
{ return boost::container::dtl::operator_delete_deallocate<T>(ptr, n); }
|
||||
|
||||
friend bool operator==(const simple_allocator &, const simple_allocator &)
|
||||
{ return true; }
|
||||
@@ -181,18 +175,11 @@ class propagation_test_allocator
|
||||
static void reset_unique_id(unsigned id = 0)
|
||||
{ unique_id_ = id; }
|
||||
|
||||
T* allocate(std::size_t n)
|
||||
{ return static_cast<T*>(::operator new(n * sizeof(T))); }
|
||||
value_type* allocate(std::size_t count)
|
||||
{ return boost::container::dtl::operator_new_allocate<value_type>(count); }
|
||||
|
||||
void deallocate(T *ptr, std::size_t n) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
(void)n;
|
||||
# if defined(__cpp_sized_deallocation)
|
||||
::operator delete((void*)ptr, n * sizeof(T));
|
||||
#else
|
||||
::operator delete((void*)ptr);
|
||||
# endif
|
||||
}
|
||||
void deallocate(value_type *ptr, std::size_t n)
|
||||
{ return boost::container::dtl::operator_delete_deallocate<T>(ptr, n); }
|
||||
|
||||
friend bool operator==(const propagation_test_allocator &a, const propagation_test_allocator &b)
|
||||
{ return EqualIfEqualIds ? a.id_ == b.id_ : true; }
|
||||
|
||||
Reference in New Issue
Block a user