From Jason Turner

[util.smartptr.shared.create]

Diff to HTML by rtfpessoa

tmp/tmpiovfs_6j/{from.md → to.md} RENAMED
@@ -1,6 +1,6 @@
1
- #### Creation <a id="util.smartptr.shared.create">[[util.smartptr.shared.create]]</a>
2
 
3
  The common requirements that apply to all `make_shared`,
4
  `allocate_shared`, `make_shared_for_overwrite`, and
5
  `allocate_shared_for_overwrite` overloads, unless specified otherwise,
6
  are described below.
@@ -14,34 +14,34 @@ template<class T, ...>
14
  shared_ptr<T> make_shared_for_overwrite(args);
15
  template<class T, class A, ...>
16
  shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
17
  ```
18
 
19
- *Preconditions:* `A` meets the *Cpp17Allocator* requirements
20
- ([[cpp17.allocator]]).
21
 
22
  *Effects:* Allocates memory for an object of type `T` (or `U[N]` when
23
  `T` is `U[]`, where `N` is determined from *args* as specified by the
24
  concrete overload). The object is initialized from *args* as specified
25
  by the concrete overload. The `allocate_shared` and
26
  `allocate_shared_for_overwrite` templates use a copy of `a` (rebound for
27
  an unspecified `value_type`) to allocate memory. If an exception is
28
  thrown, the functions have no effect.
29
 
 
 
 
30
  *Returns:* A `shared_ptr` instance that stores and owns the address of
31
  the newly constructed object.
32
 
33
- *Ensures:* `r.get() != 0 && r.use_count() == 1`, where `r` is the return
34
- value.
35
-
36
  *Throws:* `bad_alloc`, or an exception thrown from `allocate` or from
37
  the initialization of the object.
38
 
39
  *Remarks:*
40
 
41
  - Implementations should perform no more than one memory allocation.
42
- \[*Note 1*: This provides efficiency equivalent to an intrusive smart
43
  pointer. — *end note*]
44
  - When an object of an array type `U` is specified to have an initial
45
  value of `u` (of the same type), this shall be interpreted to mean
46
  that each array element of the object has as its initial value the
47
  corresponding element from `u`.
@@ -93,11 +93,11 @@ the initialization of the object.
93
  expression `allocator_traits<A2>::destroy(a2, pv)` where `pv` points
94
  to that object of type `remove_cv_t<U>` and `a2` of type `A2` is a
95
  rebound copy of the allocator `a` passed to `allocate_shared` such
96
  that its `value_type` is `remove_cv_t<U>`.
97
 
98
- [*Note 1*: These functions will typically allocate more memory than
99
  `sizeof(T)` to allow for internal bookkeeping structures such as
100
  reference counts. — *end note*]
101
 
102
  ``` cpp
103
  template<class T, class... Args>
@@ -107,11 +107,11 @@ template<class T, class A, class... Args>
107
  ```
108
 
109
  *Constraints:* `T` is not an array type.
110
 
111
  *Returns:* A `shared_ptr` to an object of type `T` with an initial value
112
- `T(forward<Args>(args)...)`.
113
 
114
  *Remarks:* The `shared_ptr` constructors called by these functions
115
  enable `shared_from_this` with the address of the newly constructed
116
  object of type `T`.
117
 
 
1
+ ##### Creation <a id="util.smartptr.shared.create">[[util.smartptr.shared.create]]</a>
2
 
3
  The common requirements that apply to all `make_shared`,
4
  `allocate_shared`, `make_shared_for_overwrite`, and
5
  `allocate_shared_for_overwrite` overloads, unless specified otherwise,
6
  are described below.
 
14
  shared_ptr<T> make_shared_for_overwrite(args);
15
  template<class T, class A, ...>
16
  shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
17
  ```
18
 
19
+ *Preconditions:* `A` meets the *Cpp17Allocator*
20
+ requirements [[allocator.requirements.general]].
21
 
22
  *Effects:* Allocates memory for an object of type `T` (or `U[N]` when
23
  `T` is `U[]`, where `N` is determined from *args* as specified by the
24
  concrete overload). The object is initialized from *args* as specified
25
  by the concrete overload. The `allocate_shared` and
26
  `allocate_shared_for_overwrite` templates use a copy of `a` (rebound for
27
  an unspecified `value_type`) to allocate memory. If an exception is
28
  thrown, the functions have no effect.
29
 
30
+ *Ensures:* `r.get() != nullptr && r.use_count() == 1`, where `r` is the
31
+ return value.
32
+
33
  *Returns:* A `shared_ptr` instance that stores and owns the address of
34
  the newly constructed object.
35
 
 
 
 
36
  *Throws:* `bad_alloc`, or an exception thrown from `allocate` or from
37
  the initialization of the object.
38
 
39
  *Remarks:*
40
 
41
  - Implementations should perform no more than one memory allocation.
42
+ \[*Note 3*: This provides efficiency equivalent to an intrusive smart
43
  pointer. — *end note*]
44
  - When an object of an array type `U` is specified to have an initial
45
  value of `u` (of the same type), this shall be interpreted to mean
46
  that each array element of the object has as its initial value the
47
  corresponding element from `u`.
 
93
  expression `allocator_traits<A2>::destroy(a2, pv)` where `pv` points
94
  to that object of type `remove_cv_t<U>` and `a2` of type `A2` is a
95
  rebound copy of the allocator `a` passed to `allocate_shared` such
96
  that its `value_type` is `remove_cv_t<U>`.
97
 
98
+ [*Note 7*: These functions will typically allocate more memory than
99
  `sizeof(T)` to allow for internal bookkeeping structures such as
100
  reference counts. — *end note*]
101
 
102
  ``` cpp
103
  template<class T, class... Args>
 
107
  ```
108
 
109
  *Constraints:* `T` is not an array type.
110
 
111
  *Returns:* A `shared_ptr` to an object of type `T` with an initial value
112
+ `T(std::forward<Args>(args)...)`.
113
 
114
  *Remarks:* The `shared_ptr` constructors called by these functions
115
  enable `shared_from_this` with the address of the newly constructed
116
  object of type `T`.
117