From Jason Turner

[default.allocator]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpb0w33u9y/{from.md → to.md} +18 -86
tmp/tmpb0w33u9y/{from.md → to.md} RENAMED
@@ -1,50 +1,25 @@
1
  ### The default allocator <a id="default.allocator">[[default.allocator]]</a>
2
 
 
 
 
3
  ``` cpp
4
  namespace std {
5
- template <class T> class allocator;
6
-
7
- // specialize for void:
8
- template <> class allocator<void> {
9
- public:
10
- typedef void* pointer;
11
- typedef const void* const_pointer;
12
- // reference-to-void members are impossible.
13
- typedef void value_type;
14
- template <class U> struct rebind { typedef allocator<U> other; };
15
- };
16
-
17
  template <class T> class allocator {
18
  public:
19
- typedef size_t size_type;
20
- typedef ptrdiff_t difference_type;
21
- typedef T* pointer;
22
- typedef const T* const_pointer;
23
- typedef T& reference;
24
- typedef const T& const_reference;
25
- typedef T value_type;
26
- template <class U> struct rebind { typedef allocator<U> other; };
27
- typedef true_type propagate_on_container_move_assignment;
28
 
29
  allocator() noexcept;
30
  allocator(const allocator&) noexcept;
31
  template <class U> allocator(const allocator<U>&) noexcept;
32
  ~allocator();
33
 
34
- pointer address(reference x) const noexcept;
35
- const_pointer address(const_reference x) const noexcept;
36
-
37
- pointer allocate(
38
- size_type, allocator<void>::const_pointer hint = 0);
39
- void deallocate(pointer p, size_type n);
40
- size_type max_size() const noexcept;
41
-
42
- template<class U, class... Args>
43
- void construct(U* p, Args&&... args);
44
- template <class U>
45
- void destroy(U* p);
46
  };
47
  }
48
  ```
49
 
50
  #### `allocator` members <a id="allocator.members">[[allocator.members]]</a>
@@ -55,89 +30,46 @@ concurrent calls to those member functions from different threads. Calls
55
  to these functions that allocate or deallocate a particular unit of
56
  storage shall occur in a single total order, and each such deallocation
57
  call shall happen before the next allocation (if any) in this order.
58
 
59
  ``` cpp
60
- pointer address(reference x) const noexcept;
61
  ```
62
 
63
- *Returns:* The actual address of the object referenced by `x`, even in
64
- the presence of an overloaded operator&.
65
-
66
- ``` cpp
67
- const_pointer address(const_reference x) const noexcept;
68
- ```
69
-
70
- *Returns:* The actual address of the object referenced by `x`, even in
71
- the presence of an overloaded operator&.
72
-
73
- ``` cpp
74
- pointer allocate(size_type n, allocator<void>::const_pointer hint = 0);
75
- ```
76
-
77
- In a container member function, the address of an adjacent element is
78
- often a good choice to pass for the `hint` argument.
79
-
80
  *Returns:* A pointer to the initial element of an array of storage of
81
  size `n` `* sizeof(T)`, aligned appropriately for objects of type `T`.
82
- It is *implementation-defined* whether over-aligned types are
83
- supported ([[basic.align]]).
84
 
85
- the storage is obtained by calling
86
- `::operator new(std::size_t)` ([[new.delete]]), but it is unspecified
87
- when or how often this function is called. The use of `hint` is
88
- unspecified, but intended as an aid to locality if an implementation so
89
- desires.
90
 
91
  *Throws:* `bad_alloc` if the storage cannot be obtained.
92
 
93
  ``` cpp
94
- void deallocate(pointer p, size_type n);
95
  ```
96
 
97
  *Requires:* `p` shall be a pointer value obtained from `allocate()`. `n`
98
  shall equal the value passed as the first argument to the invocation of
99
  allocate which returned `p`.
100
 
101
  *Effects:* Deallocates the storage referenced by `p` .
102
 
103
- *Remarks:* Uses
104
- `::operator delete(void*, std::size_t)` ([[new.delete]]), but it is
105
  unspecified when this function is called.
106
 
107
- ``` cpp
108
- size_type max_size() const noexcept;
109
- ```
110
-
111
- *Returns:* The largest value *N* for which the call `allocate(N,0)`
112
- might succeed.
113
-
114
- ``` cpp
115
- template <class U, class... Args>
116
- void construct(U* p, Args&&... args);
117
- ```
118
-
119
- *Effects:* `::new((void *)p) U(std::forward<Args>(args)...)`
120
-
121
- ``` cpp
122
- template <class U>
123
- void destroy(U* p);
124
- ```
125
-
126
- *Effects:* `p->~U()`
127
-
128
  #### `allocator` globals <a id="allocator.globals">[[allocator.globals]]</a>
129
 
130
  ``` cpp
131
- template <class T1, class T2>
132
- bool operator==(const allocator<T1>&, const allocator<T2>&) noexcept;
133
  ```
134
 
135
  *Returns:* `true`.
136
 
137
  ``` cpp
138
- template <class T1, class T2>
139
- bool operator!=(const allocator<T1>&, const allocator<T2>&) noexcept;
140
  ```
141
 
142
  *Returns:* `false`.
143
 
 
1
  ### The default allocator <a id="default.allocator">[[default.allocator]]</a>
2
 
3
+ All specializations of the default allocator satisfy the allocator
4
+ completeness requirements ([[allocator.requirements.completeness]]).
5
+
6
  ``` cpp
7
  namespace std {
 
 
 
 
 
 
 
 
 
 
 
 
8
  template <class T> class allocator {
9
  public:
10
+ using value_type = T;
11
+ using propagate_on_container_move_assignment = true_type;
12
+ using is_always_equal = true_type;
 
 
 
 
 
 
13
 
14
  allocator() noexcept;
15
  allocator(const allocator&) noexcept;
16
  template <class U> allocator(const allocator<U>&) noexcept;
17
  ~allocator();
18
 
19
+ T* allocate(size_t n);
20
+ void deallocate(T* p, size_t n);
 
 
 
 
 
 
 
 
 
 
21
  };
22
  }
23
  ```
24
 
25
  #### `allocator` members <a id="allocator.members">[[allocator.members]]</a>
 
30
  to these functions that allocate or deallocate a particular unit of
31
  storage shall occur in a single total order, and each such deallocation
32
  call shall happen before the next allocation (if any) in this order.
33
 
34
  ``` cpp
35
+ T* allocate(size_t n);
36
  ```
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  *Returns:* A pointer to the initial element of an array of storage of
39
  size `n` `* sizeof(T)`, aligned appropriately for objects of type `T`.
 
 
40
 
41
+ *Remarks:* the storage is obtained by calling
42
+ `::operator new` ([[new.delete]]), but it is unspecified when or how
43
+ often this function is called.
 
 
44
 
45
  *Throws:* `bad_alloc` if the storage cannot be obtained.
46
 
47
  ``` cpp
48
+ void deallocate(T* p, size_t n);
49
  ```
50
 
51
  *Requires:* `p` shall be a pointer value obtained from `allocate()`. `n`
52
  shall equal the value passed as the first argument to the invocation of
53
  allocate which returned `p`.
54
 
55
  *Effects:* Deallocates the storage referenced by `p` .
56
 
57
+ *Remarks:* Uses `::operator delete` ([[new.delete]]), but it is
 
58
  unspecified when this function is called.
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  #### `allocator` globals <a id="allocator.globals">[[allocator.globals]]</a>
61
 
62
  ``` cpp
63
+ template <class T, class U>
64
+ bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
65
  ```
66
 
67
  *Returns:* `true`.
68
 
69
  ``` cpp
70
+ template <class T, class U>
71
+ bool operator!=(const allocator<T>&, const allocator<U>&) noexcept;
72
  ```
73
 
74
  *Returns:* `false`.
75