diff options
Diffstat (limited to 'boost/container/detail/allocator_version_traits.hpp')
-rw-r--r-- | boost/container/detail/allocator_version_traits.hpp | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/boost/container/detail/allocator_version_traits.hpp b/boost/container/detail/allocator_version_traits.hpp index 18bb2ac613..62492da091 100644 --- a/boost/container/detail/allocator_version_traits.hpp +++ b/boost/container/detail/allocator_version_traits.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP #define BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -25,7 +29,6 @@ #include <boost/container/detail/allocation_type.hpp> //allocation_type #include <boost/container/detail/mpl.hpp> //integral_constant #include <boost/intrusive/pointer_traits.hpp> //pointer_traits -#include <utility> //pair #include <boost/core/no_exceptions_support.hpp> //BOOST_TRY namespace boost { @@ -56,14 +59,9 @@ struct allocator_version_traits static void deallocate_individual(Allocator &a, multiallocation_chain &holder) { a.deallocate_individual(holder); } - static std::pair<pointer, bool> - allocation_command(Allocator &a, allocation_type command, - size_type limit_size, size_type preferred_size, - size_type &received_size, const pointer &reuse) - { - return a.allocation_command - (command, limit_size, preferred_size, received_size, reuse); - } + static pointer allocation_command(Allocator &a, allocation_type command, + size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse) + { return a.allocation_command(command, limit_size, prefer_in_recvd_out_size, reuse); } }; template<class Allocator> @@ -132,21 +130,16 @@ struct allocator_version_traits<Allocator, 1> rollback.release(); } - static std::pair<pointer, bool> - allocation_command(Allocator &a, allocation_type command, - size_type, size_type preferred_size, - size_type &received_size, const pointer &) + static pointer allocation_command(Allocator &a, allocation_type command, + size_type, size_type &prefer_in_recvd_out_size, pointer &reuse) { - std::pair<pointer, bool> ret(pointer(), false); - if(!(command & allocate_new)){ - if(!(command & nothrow_allocation)){ - throw_logic_error("version 1 allocator without allocate_new flag"); - } + pointer ret = pointer(); + if(BOOST_UNLIKELY(!(command & allocate_new) && !(command & nothrow_allocation))){ + throw_logic_error("version 1 allocator without allocate_new flag"); } else{ - received_size = preferred_size; BOOST_TRY{ - ret.first = a.allocate(received_size); + ret = a.allocate(prefer_in_recvd_out_size); } BOOST_CATCH(...){ if(!(command & nothrow_allocation)){ @@ -154,6 +147,7 @@ struct allocator_version_traits<Allocator, 1> } } BOOST_CATCH_END + reuse = pointer(); } return ret; } |