Squashed 'third_party/boostorg/container/' content from commit 1ad6431
Change-Id: I7d095db3455264c03446268e5675b926bebedb0a
git-subtree-dir: third_party/boostorg/container
git-subtree-split: 1ad64316a432a7f021b4956acf88abc6aaa8a77e
diff --git a/include/boost/container/detail/next_capacity.hpp b/include/boost/container/detail/next_capacity.hpp
new file mode 100644
index 0000000..7e6554d
--- /dev/null
+++ b/include/boost/container/detail/next_capacity.hpp
@@ -0,0 +1,77 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2014-2015. 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)
+//
+// See http://www.boost.org/libs/container for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_CONTAINER_DETAIL_NEXT_CAPACITY_HPP
+#define BOOST_CONTAINER_DETAIL_NEXT_CAPACITY_HPP
+
+#ifndef BOOST_CONFIG_HPP
+# include <boost/config.hpp>
+#endif
+
+#if defined(BOOST_HAS_PRAGMA_ONCE)
+# pragma once
+#endif
+
+// container
+#include <boost/container/throw_exception.hpp>
+// container/detail
+#include <boost/container/detail/min_max.hpp>
+
+#include <boost/static_assert.hpp>
+
+namespace boost {
+namespace container {
+namespace dtl {
+
+template<unsigned Minimum, unsigned Numerator, unsigned Denominator>
+struct grow_factor_ratio
+{
+ BOOST_STATIC_ASSERT(Numerator > Denominator);
+ BOOST_STATIC_ASSERT(Numerator < 100);
+ BOOST_STATIC_ASSERT(Denominator < 100);
+ BOOST_STATIC_ASSERT(Denominator == 1 || (0 != Numerator % Denominator));
+
+ template<class SizeType>
+ SizeType operator()(const SizeType cur_cap, const SizeType add_min_cap, const SizeType max_cap) const
+ {
+ const SizeType overflow_limit = ((SizeType)-1) / Numerator;
+
+ SizeType new_cap = 0;
+
+ if(cur_cap <= overflow_limit){
+ new_cap = cur_cap * Numerator / Denominator;
+ }
+ else if(Denominator == 1 || (SizeType(new_cap = cur_cap) / Denominator) > overflow_limit){
+ new_cap = (SizeType)-1;
+ }
+ else{
+ new_cap *= Numerator;
+ }
+ return max_value(SizeType(Minimum), max_value(cur_cap+add_min_cap, min_value(max_cap, new_cap)));
+ }
+};
+
+} //namespace dtl {
+
+struct growth_factor_50
+ : dtl::grow_factor_ratio<0, 3, 2>
+{};
+
+struct growth_factor_60
+ : dtl::grow_factor_ratio<0, 8, 5>
+{};
+
+struct growth_factor_100
+ : dtl::grow_factor_ratio<0, 2, 1>
+{};
+
+} //namespace container {
+} //namespace boost {
+
+#endif //#ifndef BOOST_CONTAINER_DETAIL_NEXT_CAPACITY_HPP