From b378d0336cc2e294d7e5314c5ec97a562bdcd92b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 17 Dec 2017 12:38:13 +0000 Subject: [PATCH] Use allocator_traits::construct and destroy --- include/boost/functional/factory.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/boost/functional/factory.hpp b/include/boost/functional/factory.hpp index 8f59963..3a7ee6d 100644 --- a/include/boost/functional/factory.hpp +++ b/include/boost/functional/factory.hpp @@ -12,6 +12,7 @@ # include # include # include +# include # include # include @@ -117,11 +118,12 @@ namespace boost void operator()(value_type* ptr) const { if (!! ptr) { - ptr->~value_type(); #if defined(BOOST_NO_CXX11_ALLOCATOR) + ptr->~value_type(); const_cast(static_cast( this))->deallocate(ptr,1); #else + allocator_traits::destroy(this->get_allocator(), ptr); allocator_traits::deallocate(this->get_allocator(),ptr,1); #endif } @@ -186,9 +188,15 @@ namespace boost #endif try { +#if defined(BOOST_NO_CXX11_ALLOCATOR) return make_pointer( new(memory) value_type(BOOST_PP_ENUM_PARAMS(N,a)), boost::non_type() ); +#else + allocator_traits::construct(this->get_allocator(), memory + BOOST_PP_ENUM_TRAILING_PARAMS(N,a)); + return make_pointer(memory, boost::non_type()); +#endif } catch (...) { #if defined(BOOST_NO_CXX11_ALLOCATOR)