You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/standard-library/allocator-traits-class.md
+51-61Lines changed: 51 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,45 +13,41 @@ The template class describes an object that supplements an *allocator type*. An
13
13
14
14
```cpp
15
15
template <classAlloc>
16
-
classallocator_traits;
16
+
classallocator_traits;
17
17
```
18
18
19
+
## Members
20
+
19
21
### Typedefs
20
22
21
-
|Name|Description|
22
-
|----------|-----------------|
23
-
|`allocator_traits::allocator_type`|This type is a synonym for the template parameter `Alloc`.|
24
-
|`allocator_traits::const_pointer`|This type is `Alloc::const_pointer`, if that type is well-formed; otherwise, this type is `pointer_traits<pointer>::rebind<const value_type>`.|
25
-
|`allocator_traits::const_void_pointer`|This type is `Alloc::const_void_pointer`, if that type is well-formed; otherwise, this type is `pointer_traits<pointer>::rebind<const void>`.|
26
-
|`allocator_traits::difference_type`|This type is `Alloc::difference_type`, if that type is well-formed; otherwise, this type is `pointer_traits<pointer>::difference_type`.|
27
-
|`allocator_traits::pointer`|This type is `Alloc::pointer`, if that type is well-formed; otherwise, this type is `value_type *`.|
28
-
|`allocator_traits::propagate_on_container_copy_assignment`|This type is `Alloc::propagate_on_container_copy_assignment`, if that type is well-formed; otherwise, this type is `false_type`.|
29
-
|`allocator_traits::propagate_on_container_move_assignment`|This type is `Alloc::propagate_on_container_move_assignment`, if that type is well-formed; otherwise, this type is `false_type`. If the type holds true, an allocator-enabled container copies its stored allocator on a move assignment.|
30
-
|`allocator_traits::propagate_on_container_swap`|This type is `Alloc::propagate_on_container_swap`, if that type is well-formed; otherwise, this type is `false_type`. If the type holds true, an allocator-enabled container swaps its stored allocator on a swap.|
31
-
|`allocator_traits::size_type`|This type is `Alloc::size_type`, if that type is well-formed; otherwise, this type is `make_unsigned<difference_type>::type`.|
32
-
|`allocator_traits::value_type`|This type is a synonym for `Alloc::value_type`.|
33
-
|`allocator_traits::void_pointer`|This type is `Alloc::void_pointer`, if that type is well-formed; otherwise, this type is `pointer_traits<pointer>::rebind<void>`.|
23
+
|||
24
+
|-|-|
25
+
|`allocator_type`|This type is a synonym for the template parameter `Alloc`.|
26
+
|`const_pointer`|This type is `Alloc::const_pointer`, if that type is well-formed; otherwise, this type is `pointer_traits<pointer>::rebind<const value_type>`.|
27
+
|`const_void_pointer`|This type is `Alloc::const_void_pointer`, if that type is well-formed; otherwise, this type is `pointer_traits<pointer>::rebind<const void>`.|
28
+
|`difference_type`|This type is `Alloc::difference_type`, if that type is well-formed; otherwise, this type is `pointer_traits<pointer>::difference_type`.|
29
+
|`pointer`|This type is `Alloc::pointer`, if that type is well-formed; otherwise, this type is `value_type *`.|
30
+
|`propagate_on_container_copy_assignment`|This type is `Alloc::propagate_on_container_copy_assignment`, if that type is well-formed; otherwise, this type is `false_type`.|
31
+
|`propagate_on_container_move_assignment`|This type is `Alloc::propagate_on_container_move_assignment`, if that type is well-formed; otherwise, this type is `false_type`. If the type holds true, an allocator-enabled container copies its stored allocator on a move assignment.|
32
+
|`propagate_on_container_swap`|This type is `Alloc::propagate_on_container_swap`, if that type is well-formed; otherwise, this type is `false_type`. If the type holds true, an allocator-enabled container swaps its stored allocator on a swap.|
33
+
|`size_type`|This type is `Alloc::size_type`, if that type is well-formed; otherwise, this type is `make_unsigned<difference_type>::type`.|
34
+
|`value_type`|This type is a synonym for `Alloc::value_type`.|
35
+
|`void_pointer`|This type is `Alloc::void_pointer`, if that type is well-formed; otherwise, this type is `pointer_traits<pointer>::rebind<void>`.|
34
36
35
37
### Static Methods
36
38
37
39
The following static methods call the corresponding method on a given allocator parameter.
38
40
39
-
|Name|Description|
40
-
|----------|-----------------|
41
+
|||
42
+
|-|-|
41
43
|[allocate](#allocate)|Static method that allocates memory by using the given allocator parameter.|
42
44
|[construct](#construct)|Static method that uses a specified allocator to construct an object.|
43
45
|[deallocate](#deallocate)|Static method that uses a specified allocator to deallocate a specified number of objects.|
44
46
|[destroy](#destroy)|Static method that uses a specified allocator to call the destructor on an object without deallocating its memory.|
45
47
|[max_size](#max_size)|Static method that uses a specified allocator to determine the maximum number of objects that can be allocated.|
46
48
|[select_on_container_copy_construction](#select_on_container_copy_construction)|Static method that calls `select_on_container_copy_construction` on the specified allocator.|
A `const_pointer` that might assist the allocator object in satisfying the request for storage by locating the address of an allocated object prior to the request. A null pointer is treated as no hint.
75
71
76
-
### Return Value
72
+
#### Return Value
77
73
78
74
Each method returns a pointer to the allocated object.
79
75
80
76
The first static method returns `al.allocate(count)`.
81
77
82
78
The second method returns `al.allocate(count, hint)`, if that expression is well formed; otherwise it returns `al.allocate(count)`.
A pointer to the location where the object is to be constructed.
100
96
101
-
*args*<br/>
97
+
*args*\
102
98
A list of arguments that is passed to the object constructor.
103
99
104
-
### Remarks
100
+
####Remarks
105
101
106
102
The static member function calls `al.construct(ptr, args...)`, if that expression is well formed; otherwise it evaluates `::new (static_cast<void *>(ptr)) Uty(std::forward<Types>(args)...)`.
0 commit comments