diff options
Diffstat (limited to 'boost/multi_index/detail/copy_map.hpp')
-rw-r--r-- | boost/multi_index/detail/copy_map.hpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/boost/multi_index/detail/copy_map.hpp b/boost/multi_index/detail/copy_map.hpp index 9a34b259cf..1ab2bf0043 100644 --- a/boost/multi_index/detail/copy_map.hpp +++ b/boost/multi_index/detail/copy_map.hpp @@ -1,4 +1,4 @@ -/* Copyright 2003-2015 Joaquin M Lopez Munoz. +/* Copyright 2003-2018 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -15,12 +15,14 @@ #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <algorithm> +#include <boost/core/addressof.hpp> #include <boost/detail/no_exceptions_support.hpp> #include <boost/multi_index/detail/auto_space.hpp> #include <boost/multi_index/detail/raw_ptr.hpp> #include <boost/noncopyable.hpp> #include <cstddef> #include <functional> +#include <memory> namespace boost{ @@ -70,7 +72,8 @@ public: { if(!released){ for(std::size_t i=0;i<n;++i){ - boost::detail::allocator::destroy(&(spc.data()+i)->second->value()); + boost::detail::allocator::destroy( + boost::addressof((spc.data()+i)->second->value())); deallocate((spc.data()+i)->second); } } @@ -82,10 +85,10 @@ public: void clone(Node* node) { (spc.data()+n)->first=node; - (spc.data()+n)->second=raw_ptr<Node*>(al_.allocate(1)); + (spc.data()+n)->second=raw_ptr<Node*>(allocate()); BOOST_TRY{ boost::detail::allocator::construct( - &(spc.data()+n)->second->value(),node->value()); + boost::addressof((spc.data()+n)->second->value()),node->value()); } BOOST_CATCH(...){ deallocate((spc.data()+n)->second); @@ -117,7 +120,12 @@ private: typedef typename boost::detail::allocator::rebind_to< Allocator,Node >::type allocator_type; +#ifdef BOOST_NO_CXX11_ALLOCATOR typedef typename allocator_type::pointer allocator_pointer; +#else + typedef std::allocator_traits<allocator_type> allocator_traits; + typedef typename allocator_traits::pointer allocator_pointer; +#endif allocator_type al_; std::size_t size_; @@ -127,9 +135,22 @@ private: Node* header_cpy_; bool released; + allocator_pointer allocate() + { +#ifdef BOOST_NO_CXX11_ALLOCATOR + return al_.allocate(1); +#else + return allocator_traits::allocate(al_,1); +#endif + } + void deallocate(Node* node) { +#ifdef BOOST_NO_CXX11_ALLOCATOR al_.deallocate(static_cast<allocator_pointer>(node),1); +#else + allocator_traits::deallocate(al_,static_cast<allocator_pointer>(node),1); +#endif } }; |