4#ifndef TETL_MEMORY_ALLOCATOR_TRAITS_HPP
5#define TETL_MEMORY_ALLOCATOR_TRAITS_HPP
7#include <etl/_memory/pointer_traits.hpp>
8#include <etl/_type_traits/make_unsigned.hpp>
14template <
typename Alloc>
15struct allocator_traits_pointer {
16 using type =
typename Alloc::value_type*;
19template <
typename Alloc>
20 requires requires {
typename Alloc::pointer; }
21struct allocator_traits_pointer<Alloc> {
22 using type =
typename Alloc::pointer;
25template <
typename Alloc>
26struct allocator_traits_const_pointer {
27 using pointer =
typename allocator_traits_pointer<Alloc>::type;
28 using type =
typename etl::
pointer_traits<pointer>::
template rebind<
typename Alloc::value_type
const>;
31template <
typename Alloc>
32 requires requires {
typename Alloc::const_pointer; }
33struct allocator_traits_const_pointer<Alloc> {
34 using type =
typename Alloc::const_pointer;
37template <
typename Alloc>
38struct allocator_traits_void_pointer {
39 using pointer =
typename allocator_traits_pointer<Alloc>::type;
43template <
typename Alloc>
44 requires requires {
typename Alloc::void_pointer; }
45struct allocator_traits_void_pointer<Alloc> {
46 using type =
typename Alloc::void_pointer;
49template <
typename Alloc>
50struct allocator_traits_const_void_pointer {
51 using pointer =
typename allocator_traits_pointer<Alloc>::type;
55template <
typename Alloc>
56 requires requires {
typename Alloc::const_void_pointer; }
57struct allocator_traits_const_void_pointer<Alloc> {
58 using type =
typename Alloc::const_void_pointer;
61template <
typename Alloc>
62struct allocator_traits_difference_type {
63 using pointer =
typename allocator_traits_pointer<Alloc>::type;
67template <
typename Alloc>
68 requires requires {
typename Alloc::difference_type; }
69struct allocator_traits_difference_type<Alloc> {
70 using type =
typename Alloc::difference_type;
73template <
typename Alloc>
74struct allocator_traits_size_type {
75 using difference_type =
typename allocator_traits_difference_type<Alloc>::type;
76 using type =
etl::make_unsigned_t<difference_type>;
79template <
typename Alloc>
80 requires requires {
typename Alloc::size_type; }
81struct allocator_traits_size_type<Alloc> {
82 using type =
typename Alloc::size_type;
87template <
typename Alloc>
89 using allocator_type = Alloc;
90 using value_type =
typename Alloc::value_type;
91 using pointer =
typename detail::allocator_traits_pointer<Alloc>::type;
92 using const_pointer =
typename detail::allocator_traits_const_pointer<Alloc>::type;
93 using void_pointer =
typename detail::allocator_traits_void_pointer<Alloc>::type;
94 using const_void_pointer =
typename detail::allocator_traits_const_void_pointer<Alloc>::type;
95 using difference_type =
typename detail::allocator_traits_difference_type<Alloc>::type;
96 using size_type =
typename detail::allocator_traits_size_type<Alloc>::type;
100 return a.allocate(n);
103 static constexpr void deallocate(Alloc& a, pointer p, size_type n)
Definition adjacent_find.hpp:9
Definition allocator_traits.hpp:88
static constexpr auto allocate(Alloc &a, size_type n)
Definition allocator_traits.hpp:98
static constexpr void deallocate(Alloc &a, pointer p, size_type n)
Definition allocator_traits.hpp:103
The pointer_traits class template provides the standardized way to access certain properties of point...
Definition pointer_traits.hpp:18