diff options
Diffstat (limited to 'boost/detail/dynamic_bitset.hpp')
-rw-r--r-- | boost/detail/dynamic_bitset.hpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/boost/detail/dynamic_bitset.hpp b/boost/detail/dynamic_bitset.hpp index 281aa55cd6..e0f675d5ec 100644 --- a/boost/detail/dynamic_bitset.hpp +++ b/boost/detail/dynamic_bitset.hpp @@ -3,6 +3,9 @@ // Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek // Copyright (c) 2003-2006, 2008 Gennaro Prota // +// Copyright (c) 2014 Glen Joseph Fernandes +// glenfe at live dot com +// // 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) @@ -12,6 +15,7 @@ #ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP #define BOOST_DETAIL_DYNAMIC_BITSET_HPP +#include <memory> #include <cstddef> #include "boost/config.hpp" #include "boost/detail/workaround.hpp" @@ -155,17 +159,25 @@ namespace boost { // meaningful info. // template <typename T> - typename T::size_type vector_max_size_workaround(const T & v) { + inline typename T::size_type vector_max_size_workaround(const T & v) + BOOST_NOEXCEPT + { + typedef typename T::allocator_type allocator_type; + + const allocator_type& alloc = v.get_allocator(); - typedef typename T::allocator_type allocator_type; +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef std::allocator_traits<allocator_type> allocator_traits; + + const typename allocator_traits::size_type alloc_max = + allocator_traits::max_size(alloc); +#else + const typename allocator_type::size_type alloc_max = alloc.max_size(); +#endif - const typename allocator_type::size_type alloc_max = - v.get_allocator().max_size(); - const typename T::size_type container_max = v.max_size(); + const typename T::size_type container_max = v.max_size(); - return alloc_max < container_max? - alloc_max : - container_max; + return alloc_max < container_max ? alloc_max : container_max; } // for static_asserts |