forked from boostorg/container
* Fixed adaptive pool bugs
* Improved adaptive pool testing enabling invariant checking in debug mode. * New compile-time and runtime calculated parameters for adaptive_pool. * New test comparing set with default allocator or adaptive pool
This commit is contained in:
1 parent
42c6be5887
commit
04b0791593
9 files changed
+1398
-512
No files matched your search
@@ -94,6 +94,34 @@ inline Integer upper_power_of_2(const Integer & A)
|
||||
return power_of_2;
|
||||
}
|
||||
|
||||
template <typename Integer, bool Loop = true>
|
||||
struct upper_power_of_2_loop_ct
|
||||
{
|
||||
|
||||
template <Integer I, Integer P>
|
||||
struct apply
|
||||
{
|
||||
static const Integer value =
|
||||
upper_power_of_2_loop_ct<Integer, (I > P*2)>::template apply<I, P*2>::value;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Integer>
|
||||
struct upper_power_of_2_loop_ct<Integer, false>
|
||||
{
|
||||
template <Integer I, Integer P>
|
||||
struct apply
|
||||
{
|
||||
static const Integer value = P;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Integer, Integer I>
|
||||
struct upper_power_of_2_ct
|
||||
{
|
||||
static const Integer value = upper_power_of_2_loop_ct<Integer, (I > 1)>::template apply<I, 2>::value;
|
||||
};
|
||||
|
||||
//This function uses binary search to discover the
|
||||
//highest set bit of the integer
|
||||
inline std::size_t floor_log2 (std::size_t x)
|
||||
@@ -114,6 +142,32 @@ inline std::size_t floor_log2 (std::size_t x)
|
||||
return log2;
|
||||
}
|
||||
|
||||
template<std::size_t I1, std::size_t I2>
|
||||
struct gcd_ct
|
||||
{
|
||||
static const std::size_t Max = I1 > I2 ? I1 : I2;
|
||||
static const std::size_t Min = I1 < I2 ? I1 : I2;
|
||||
static const std::size_t value = gcd_ct<Min, Max % Min>::value;
|
||||
};
|
||||
|
||||
template<std::size_t I1>
|
||||
struct gcd_ct<I1, 0>
|
||||
{
|
||||
static const std::size_t value = I1;
|
||||
};
|
||||
|
||||
template<std::size_t I1>
|
||||
struct gcd_ct<0, I1>
|
||||
{
|
||||
static const std::size_t value = I1;
|
||||
};
|
||||
|
||||
template<std::size_t I1, std::size_t I2>
|
||||
struct lcm_ct
|
||||
{
|
||||
static const std::size_t value = I1 * I2 / gcd_ct<I1, I2>::value;
|
||||
};
|
||||
|
||||
} // namespace dtl
|
||||
} // namespace container
|
||||
} // namespace boost
|
||||
|
||||
Reference in new issue
Block a user