From 3ac6dbbf08ac75b2c6ced01a7f2356389686d00d Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Tue, 4 Feb 2014 14:57:34 -0800 Subject: [PATCH] Make detail::as_allocator template C++11 friendly --- .../smart_ptr/detail/array_allocator.hpp | 25 +++++++++++++------ .../boost/smart_ptr/detail/array_deleter.hpp | 2 -- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/boost/smart_ptr/detail/array_allocator.hpp b/include/boost/smart_ptr/detail/array_allocator.hpp index bac8984..5c6baf4 100644 --- a/include/boost/smart_ptr/detail/array_allocator.hpp +++ b/include/boost/smart_ptr/detail/array_allocator.hpp @@ -143,21 +143,32 @@ namespace boost { #endif } - void construct(pointer memory, const Y& value) { #if !defined(BOOST_NO_CXX11_ALLOCATOR) - YT::construct(pair, memory, value); +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ + !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + void construct(U* memory, Args&&... args) { + YT::construct(pair, memory, std::forward(args)...); + } #else - pair.construct(memory, value); + template + void construct(U* memory, const Y& value) { + YT::construct(pair, memory, value); + } #endif + template + void destroy(U* memory) { + YT::destroy(pair, memory); + } +#else + void construct(pointer memory, const Y& value) { + pair.construct(memory, value); } void destroy(pointer memory) { -#if !defined(BOOST_NO_CXX11_ALLOCATOR) - YT::destroy(pair, memory); -#else pair.destroy(memory); -#endif } +#endif template bool operator==(const as_allocator& other) const { diff --git a/include/boost/smart_ptr/detail/array_deleter.hpp b/include/boost/smart_ptr/detail/array_deleter.hpp index b4ed44f..5fd7e43 100644 --- a/include/boost/smart_ptr/detail/array_deleter.hpp +++ b/include/boost/smart_ptr/detail/array_deleter.hpp @@ -74,7 +74,6 @@ namespace boost { } private: - #if !defined(BOOST_NO_CXX11_ALLOCATOR) typedef typename std::allocator_traits:: template rebind_alloc TA; @@ -314,7 +313,6 @@ namespace boost { #endif } - private: type* object; }; }