From Jason Turner

[allocator.requirements]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp7n_w3ez4/{from.md → to.md} +56 -23
tmp/tmp7n_w3ez4/{from.md → to.md} RENAMED
@@ -8,12 +8,12 @@ this allocation model, as well as the memory allocation and deallocation
8
  primitives for it. All of the string types (Clause  [[strings]]),
9
  containers (Clause  [[containers]]) (except array), string buffers and
10
  string streams (Clause  [[input.output]]), and `match_results` (Clause 
11
  [[re]]) are parameterized in terms of allocators.
12
 
13
- The template struct `allocator_traits` ([[allocator.traits]]) supplies
14
- a uniform interface to all allocator types. Table  [[tab:desc.var.def]]
15
  describes the types manipulated through allocators. Table 
16
  [[tab:utilities.allocator.requirements]] describes the requirements on
17
  allocator types and thus on types used to instantiate
18
  `allocator_traits`. A requirement is optional if the last column of
19
  Table  [[tab:utilities.allocator.requirements]] specifies a default for
@@ -24,31 +24,47 @@ of `allocator_traits` may provide different defaults and may provide
24
  defaults for different requirements than the primary template. Within
25
  Tables  [[tab:desc.var.def]] and 
26
  [[tab:utilities.allocator.requirements]], the use of `move` and
27
  `forward` always refers to `std::move` and `std::forward`, respectively.
28
 
 
 
29
  Note A: The member class template `rebind` in the table above is
30
- effectively a typedef template. In general, if the name `Allocator` is
31
- bound to `SomeAllocator<T>`, then `Allocator::rebind<U>::other` is the
32
- same type as `SomeAllocator<U>`, where `SomeAllocator<T>::value_type` is
33
- `T` and `SomeAllocator<U>::{}value_type` is `U`. If `Allocator` is a
34
- class template instantiation of the form `SomeAllocator<T, Args>`, where
35
- `Args` is zero or more type arguments, and `Allocator` does not supply a
36
- `rebind` member template, the standard `allocator_traits` template uses
37
- `SomeAllocator<U, Args>` in place of `Allocator::{}rebind<U>::other` by
38
- default. For allocator types that are not template instantiations of the
39
- above form, no default is provided.
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  An allocator type `X` shall satisfy the requirements of
42
  `CopyConstructible` ([[utility.arg.requirements]]). The `X::pointer`,
43
  `X::const_pointer`, `X::void_pointer`, and `X::const_void_pointer` types
44
  shall satisfy the requirements of `NullablePointer` (
45
- [[nullablepointer.requirements]]). No constructor, comparison operator,
46
- copy operation, move operation, or swap operation on these types shall
47
- exit via an exception. `X::pointer` and `X::const_pointer` shall also
48
- satisfy the requirements for a random access iterator (
49
- [[iterator.requirements]]).
 
50
 
51
  Let `x1` and `x2` denote objects of (possibly different) types
52
  `X::void_pointer`, `X::const_void_pointer`, `X::pointer`, or
53
  `X::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
54
  pointer values, if and only if both `x1` and `x2` can be explicitly
@@ -82,15 +98,18 @@ p1 - p2
82
 
83
  either or both objects may be replaced by an equivalently-valued object
84
  of type `X::const_pointer` with no change in semantics.
85
 
86
  An allocator may constrain the types on which it can be instantiated and
87
- the arguments for which its `construct` member may be called. If a type
88
- cannot be used with a particular allocator, the allocator class or the
89
- call to `construct` may fail to instantiate.
 
90
 
91
- the following is an allocator class template supporting the minimal
 
 
92
  interface that satisfies the requirements of Table 
93
  [[tab:utilities.allocator.requirements]]:
94
 
95
  ``` cpp
96
  template <class Tp>
@@ -108,11 +127,25 @@ template <class T, class U>
108
  bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
109
  template <class T, class U>
110
  bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
111
  ```
112
 
 
 
113
  If the alignment associated with a specific over-aligned type is not
114
  supported by an allocator, instantiation of the allocator for that type
115
  may fail. The allocator also may silently ignore the requested
116
- alignment. Additionally, the member function `allocate` for that type
117
- may fail by throwing an object of type `std::bad_alloc`.
 
 
 
 
 
 
 
 
 
 
 
 
118
 
 
8
  primitives for it. All of the string types (Clause  [[strings]]),
9
  containers (Clause  [[containers]]) (except array), string buffers and
10
  string streams (Clause  [[input.output]]), and `match_results` (Clause 
11
  [[re]]) are parameterized in terms of allocators.
12
 
13
+ The class template `allocator_traits` ([[allocator.traits]]) supplies a
14
+ uniform interface to all allocator types. Table  [[tab:desc.var.def]]
15
  describes the types manipulated through allocators. Table 
16
  [[tab:utilities.allocator.requirements]] describes the requirements on
17
  allocator types and thus on types used to instantiate
18
  `allocator_traits`. A requirement is optional if the last column of
19
  Table  [[tab:utilities.allocator.requirements]] specifies a default for
 
24
  defaults for different requirements than the primary template. Within
25
  Tables  [[tab:desc.var.def]] and 
26
  [[tab:utilities.allocator.requirements]], the use of `move` and
27
  `forward` always refers to `std::move` and `std::forward`, respectively.
28
 
29
+ [*Note 1*: If `n == 0`, the return value is unspecified. — *end note*]
30
+
31
  Note A: The member class template `rebind` in the table above is
32
+ effectively a typedef template.
33
+
34
+ [*Note 2*: In general, if the name `Allocator` is bound to
35
+ `SomeAllocator<T>`, then `Allocator::rebind<U>::other` is the same type
36
+ as `SomeAllocator<U>`, where `SomeAllocator<T>::value_type` is `T` and
37
+ `SomeAllocator<U>::{}value_type` is `U`. *end note*]
38
+
39
+ If `Allocator` is a class template instantiation of the form
40
+ `SomeAllocator<T, Args>`, where `Args` is zero or more type arguments,
41
+ and `Allocator` does not supply a `rebind` member template, the standard
42
+ `allocator_traits` template uses `SomeAllocator<U, Args>` in place of
43
+ `Allocator::{}rebind<U>::other` by default. For allocator types that are
44
+ not template instantiations of the above form, no default is provided.
45
+
46
+ Note B: If `X::propagate_on_container_copy_assignment::value` is `true`,
47
+ `X` shall satisfy the `CopyAssignable` requirements (Table 
48
+ [[tab:copyassignable]]) and the copy operation shall not throw
49
+ exceptions. If `X::propagate_on_container_move_assignment::value` is
50
+ `true`, `X` shall satisfy the `MoveAssignable` requirements (Table 
51
+ [[tab:moveassignable]]) and the move operation shall not throw
52
+ exceptions. If `X::propagate_on_container_swap::value` is `true`,
53
+ lvalues of type `X` shall be swappable ([[swappable.requirements]]) and
54
+ the `swap` operation shall not throw exceptions.
55
 
56
  An allocator type `X` shall satisfy the requirements of
57
  `CopyConstructible` ([[utility.arg.requirements]]). The `X::pointer`,
58
  `X::const_pointer`, `X::void_pointer`, and `X::const_void_pointer` types
59
  shall satisfy the requirements of `NullablePointer` (
60
+ [[nullablepointer.requirements]]). No constructor, comparison function,
61
+ copy operation, move operation, or swap operation on these pointer types
62
+ shall exit via an exception. `X::pointer` and `X::const_pointer` shall
63
+ also satisfy the requirements for a random access iterator (
64
+ [[random.access.iterators]]) and of a contiguous iterator (
65
+ [[iterator.requirements.general]]).
66
 
67
  Let `x1` and `x2` denote objects of (possibly different) types
68
  `X::void_pointer`, `X::const_void_pointer`, `X::pointer`, or
69
  `X::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
70
  pointer values, if and only if both `x1` and `x2` can be explicitly
 
98
 
99
  either or both objects may be replaced by an equivalently-valued object
100
  of type `X::const_pointer` with no change in semantics.
101
 
102
  An allocator may constrain the types on which it can be instantiated and
103
+ the arguments for which its `construct` or `destroy` members may be
104
+ called. If a type cannot be used with a particular allocator, the
105
+ allocator class or the call to `construct` or `destroy` may fail to
106
+ instantiate.
107
 
108
+ [*Example 1*:
109
+
110
+ The following is an allocator class template supporting the minimal
111
  interface that satisfies the requirements of Table 
112
  [[tab:utilities.allocator.requirements]]:
113
 
114
  ``` cpp
115
  template <class Tp>
 
127
  bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
128
  template <class T, class U>
129
  bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
130
  ```
131
 
132
+ — *end example*]
133
+
134
  If the alignment associated with a specific over-aligned type is not
135
  supported by an allocator, instantiation of the allocator for that type
136
  may fail. The allocator also may silently ignore the requested
137
+ alignment.
138
+
139
+ [*Note 3*: Additionally, the member function `allocate` for that type
140
+ may fail by throwing an object of type `bad_alloc`. — *end note*]
141
+
142
+ ##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
143
+
144
+ If `X` is an allocator class for type `T`, `X` additionally satisfies
145
+ the allocator completeness requirements if, whether or not `T` is a
146
+ complete type:
147
+
148
+ - `X` is a complete type, and
149
+ - all the member types of `allocator_traits<X>` ([[allocator.traits]])
150
+ other than `value_type` are complete types.
151