12 #include "allocator_base.hpp"
13 #include "internal/reallocator.hpp"
16 inline namespace v_100 {
26 template <
size_t Threshold,
class SmallAllocator,
class LargeAllocator>
27 class segregator :
private SmallAllocator,
private LargeAllocator
30 "Small- and Large-Allocator cannot be both of base!");
33 using small_allocator = SmallAllocator;
34 using large_allocator = LargeAllocator;
36 static constexpr
size_t threshold = Threshold;
38 static constexpr
bool supports_truncated_deallocation =
39 SmallAllocator::supports_truncated_deallocation &&
40 LargeAllocator::supports_truncated_deallocation;
42 static constexpr
unsigned alignment =
43 (SmallAllocator::alignment > LargeAllocator::alignment) ?
44 SmallAllocator::alignment : LargeAllocator::alignment;
56 result = SmallAllocator::allocate(n);
60 result = LargeAllocator::allocate(n);
75 if (b.length <= Threshold) {
76 return SmallAllocator::deallocate(b);
78 return LargeAllocator::deallocate(b);
91 if (internal::is_reallocation_handled_default(*
this, b, n)) {
95 if (b.length <= Threshold) {
97 return SmallAllocator::reallocate(b, n);
102 if (n <= Threshold) {
105 return LargeAllocator::reallocate(b, n);
115 template <
typename U = SmallAllocator,
typename V = LargeAllocator>
116 typename std::enable_if<traits::has_expand<SmallAllocator>::value ||
120 if (b.length <= Threshold && b.length + delta > Threshold) {
123 if (b.length <= Threshold) {
143 template <
typename U = SmallAllocator,
typename V = LargeAllocator>
144 typename std::enable_if<traits::has_expand<SmallAllocator>::value ||
148 if (b.length <= Threshold) {
158 template <
typename U = SmallAllocator,
typename V = LargeAllocator>
159 typename std::enable_if<traits::has_expand<SmallAllocator>::value ||
167 using namespace v_100;
bool reallocate(block &b, size_t n) noexcept
void deallocate(block &b) noexcept
std::enable_if< traits::has_expand< SmallAllocator >::value||traits::has_expand< LargeAllocator >::value, bool >::type expand(block &b, size_t delta) noexcept
bool reallocate_with_copy(OldAllocator &oldAllocator, NewAllocator &newAllocator, block &b, size_t n) noexcept
std::enable_if< traits::has_expand< SmallAllocator >::value||traits::has_expand< LargeAllocator >::value, bool >::type owns(const block &b) const noexcept
std::enable_if< traits::has_expand< SmallAllocator >::value||traits::has_expand< LargeAllocator >::value, void >::type deallocate_all() noexcept
block allocate(size_t n) noexcept