mirror of
https://github.com/boostorg/functional.git
synced 2025-07-31 04:57:16 +02:00
Use allocator_traits::construct and destroy
This commit is contained in:
@ -12,6 +12,7 @@
|
|||||||
# include <boost/preprocessor/iteration/iterate.hpp>
|
# include <boost/preprocessor/iteration/iterate.hpp>
|
||||||
# include <boost/preprocessor/repetition/enum_params.hpp>
|
# include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||||
|
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||||
|
|
||||||
# include <new>
|
# include <new>
|
||||||
# include <boost/pointee.hpp>
|
# include <boost/pointee.hpp>
|
||||||
@ -117,11 +118,12 @@ namespace boost
|
|||||||
void operator()(value_type* ptr) const
|
void operator()(value_type* ptr) const
|
||||||
{
|
{
|
||||||
if (!! ptr) {
|
if (!! ptr) {
|
||||||
ptr->~value_type();
|
|
||||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
ptr->~value_type();
|
||||||
const_cast<allocator_type*>(static_cast<allocator_type const*>(
|
const_cast<allocator_type*>(static_cast<allocator_type const*>(
|
||||||
this))->deallocate(ptr,1);
|
this))->deallocate(ptr,1);
|
||||||
#else
|
#else
|
||||||
|
allocator_traits::destroy(this->get_allocator(), ptr);
|
||||||
allocator_traits::deallocate(this->get_allocator(),ptr,1);
|
allocator_traits::deallocate(this->get_allocator(),ptr,1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -186,9 +188,15 @@ namespace boost
|
|||||||
#endif
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
return make_pointer(
|
return make_pointer(
|
||||||
new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a)),
|
new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a)),
|
||||||
boost::non_type<factory_alloc_propagation,AP>() );
|
boost::non_type<factory_alloc_propagation,AP>() );
|
||||||
|
#else
|
||||||
|
allocator_traits::construct(this->get_allocator(), memory
|
||||||
|
BOOST_PP_ENUM_TRAILING_PARAMS(N,a));
|
||||||
|
return make_pointer(memory, boost::non_type<factory_alloc_propagation,AP>());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
|
Reference in New Issue
Block a user