30 #ifndef BIT_MEMORY_TRAITS_ALLOCATOR_TRAITS_HPP 31 #define BIT_MEMORY_TRAITS_ALLOCATOR_TRAITS_HPP 33 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 35 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 37 #include "../utilities/allocator_info.hpp" 38 #include "../utilities/errors.hpp" 39 #include "../utilities/macros.hpp" 40 #include "../utilities/owner.hpp" 41 #include "../utilities/pointer_utilities.hpp" 42 #include "../utilities/uninitialized_storage.hpp" 44 #include "../concepts/Allocator.hpp" 46 #include <type_traits> 57 template<
typename Allocator,
typename T,
typename=
void>
58 struct allocator_pointer_rebind
60 using type =
typename std::pointer_traits<allocator_pointer_t<Allocator>>::template rebind<T>;
63 template<
typename Allocator,
typename T>
64 struct allocator_pointer_rebind<Allocator,T,void_t<typename Allocator::template pointer_rebind<T>>>
66 using type =
typename Allocator::template pointer_rebind<T>;
80 template<
typename Allocator>
84 "Allocator must be an Allocator" );
87 struct negation : std::integral_constant<bool,!T::value>{};
95 using pointer = allocator_pointer_t<Allocator>;
96 using const_pointer = allocator_const_pointer_t<Allocator>;
97 using size_type = allocator_size_type_t<Allocator>;
98 using difference_type = allocator_difference_type_t<Allocator>;
104 using pointer_rebind =
typename detail::allocator_pointer_rebind<Allocator,T>::type;
111 using uses_pretty_pointers = negation<std::is_same<void*,pointer_rebind<void>>>;
115 template<
typename Po
inter>
116 static constexpr
bool is_typed_pointer = std::is_same<typename std::pointer_traits<Pointer>::template rebind<void>,
135 static pointer try_allocate( Allocator& alloc,
137 size_type align ) noexcept;
138 static pointer try_allocate( Allocator& alloc,
141 size_type align ) noexcept;
158 static pointer allocate( Allocator& alloc,
161 static pointer allocate( Allocator& alloc,
183 static bool expand( Allocator& alloc,
185 size_type new_size );
199 static void deallocate( Allocator& alloc, pointer p, size_type size );
206 template<
typename U = Allocator,
typename = std::enable_if<can_truncate_deallocations::value>>
207 static void deallocate_all( Allocator& alloc );
230 template<
typename T,
typename...Args>
231 static void construct( Allocator& alloc,
void* p, Args&&...args );
242 template<
typename T,
typename...Args>
243 static typename detail::allocator_pointer_rebind<Allocator,T>::type
244 make( Allocator& alloc, Args&&...args );
259 static typename std::pointer_traits<pointer>::template rebind<T>
260 make_array( Allocator& alloc, size_type n );
262 static typename std::pointer_traits<pointer>::template rebind<T>
263 make_array( Allocator& alloc, size_type n,
const T& copy );
276 static void destroy( Allocator& alloc, T* p );
298 template<
typename Pointer,
299 typename=std::enable_if_t<is_typed_pointer<Pointer>>>
300 static void dispose( Allocator& alloc,
const Pointer& p );
322 template<
typename Pointer,
323 typename=std::enable_if_t<is_typed_pointer<Pointer>>>
324 static void dispose_array( Allocator& alloc,
const Pointer& p, size_type n );
341 size_type recommended_allocation_size(
const Allocator& alloc,
342 size_type requested );
356 static bool owns(
const Allocator& alloc, const_pointer p ) noexcept;
386 static typename std::pointer_traits<pointer>::template rebind<T>
387 pointer_to( Allocator& alloc, T& x ) noexcept;
399 template<
typename Pointer,
400 typename=std::enable_if_t<is_typed_pointer<Pointer>>>
401 static typename std::pointer_traits<Pointer>::element_type*
402 to_raw_pointer( Allocator& alloc,
403 const Pointer& p ) noexcept;
417 static bool is_unbounded(
const Allocator& alloc ) noexcept;
431 static size_type max_size(
const Allocator& alloc ) noexcept;
439 static size_type min_size(
const Allocator& alloc ) noexcept;
444 #include "detail/allocator_traits.inl" typename detail::allocator_pointer_rebind< Allocator, T >::type pointer_rebind
Rebinds a pointer to the new pointer type.
Type-trait to determine whether T has a 'deallocate_all' function.
Type-trait to determine the default alignment of the given T.
The allocator_traits class template provides a standardized way to access allocator functionality...
Type-trait to determine whether T satisfies the minimum requirements to be an Allocator.
Type-trait to determine the maximum alignment of the given T.
Type-trait to determine whether T has an 'owns' function.
This type is used to hold the generic information for a given allocator.